how to translate this matlab code to fortran
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
fid = fopen (CMNfile(I).name, 'r');
First get the receiver position in the CMN file: this info is on line 3
i = 1;
while 1
line = fgetl(fid);
if ~ischar(line)
Rx = [ ];
break
end
if i>3, break, end
if (i==3)
[t] = sscanf(line, '%f %f %f');
Rx = [t(3) t(1) t(2)];
end
i=i+1;
end
%receiver position done.
%%Now look for the required time
%%use the same fid because its still the same file.
out = textscan (fid, '%*f %f %*f %f %f %*f %*f %f %*f %*f', 'HeaderLines',5);
I translate this matlab function
fid = fopen (CMNfile(I).name, 'r')
to this fortran
open (unit=10, file='CMNfile(I).name', status='old',ACCESS ='READ')
but I don't know how to change fgetl, ischar, sscanf, textscan..... plz help me
0 comentarios
Respuestas (1)
Walter Roberson
el 15 de Dic. de 2015
I already showed you how to deal with the ischar() and sscanf() in your earlier question.
Is CMNfile being created by dir() ? If so then you are going to have difficulties replicating that. Using file='CMNfile(I).name' is not correct. Are you using MS Windows or Linux or OS-X ?
Replacing textscan() to read a file of unknown length is a bit of pain because Fortran does not allow arrays to be grown at need, at least not in any clean way. See https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/385790
Which Fortran compiler are you using? Can you use g77?
2 comentarios
Walter Roberson
el 15 de Dic. de 2015
If you use
mex -setup fortran
Then which compiler does it say is installed?
Ver también
Categorías
Más información sobre Fortran with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!