Hello everyone,
I am a student, seeking a support to achieve my research please.
I have Fortran program (about 2140 lines) that returns to 1992. I want to convert it to Matlab but still struggling to find a proper way. I tried Online Fortran to Matlab Converter but the maximum it can convert is 200 lines. I believe if I convert each 200 line then it loses the program structure.
Besides, I’m beginner in Fortran.
Do you really need to convert the Fortran program to Matlab, or could you use Fortran MEX API - MATLAB & Simulink? For conversion there is
f2matlab: converts Fortran 90 code to Matlab m-files, by benbarrowes. Accordingly, only basic data types and constructions are recommended.
Are you able to compile the Fortran program with gfortran or another compiler? You need to do that to check that a Matlab version works correctly. If the program is from 1992 it is likely written in Fortran 77 or an earlier version of Fortran. There are Fortran 77 tutorials at the Fortran Wiki.
I do not know whether it might be useful to try to understand the program and then to rewrite it manually.
Can you lift the veil of uncertainty about the program? Among us there are specialists in various fields, perhaps they can also give advice.
I can help with f2matlab if it has a problem during the conversion. PM if you have a problem, once you have tried f2matlab from the matlab file exchange.
What you mean by " lift the veil of uncertainty " ?
I would appreciate that. Thank you
I installed f2matlab in macbook, but I don’t know how to use it despite I read readme file.
I can open f2matlab.m file but not clear for the next step.
Please advise
The program is more than 2140 lines. Besides, Im beginner in Fortran and running out of time to finish my research.
Tell us the name of the program and from which field of the science it is
David91. Put f2matlab on your matlab path (see pathtool). Then use f2matlab like this:
f2matlab(‘yourFortranFileName’)
And, like I mentioned, you can PM (private mail) me at: barrowes@alum.mit.edu
I want to run the program in matlab platform, either converted directly to matlab code or called through MEX. The purpose to use Matlab is to simplify plotting the graphs.
I tried with MEX but seemed quite difficult to continue.
I followed instructions from the link " Create Fortran Source MEX File - MATLAB & Simulink - MathWorks Nordic", but it did not work for configuring MEX as follows :
mex -R2023b timestwo.F
Error using mex
Unknown MEX argument ‘-R2023b’.
It calculates attenuation of EM.
Note that the -R2018a
in the example is not to indicate the version of your MATLAB (it would be bizarre if MATLAB actually needed us to indicate that, no?). See
Consequently, you should not use -R2023b
, which is not a valid option. Just remove it.