kindly help in the conversion of fortran code to matlab
Show older comments


5 Comments
Walter Roberson
on 10 Apr 2020
Is th a function or an array declared with indices that start from 0 ?
Walter Roberson
on 10 Apr 2020
do j=0,m
would be written in MATLAB as
for j=0:m
end do would be written in MATLAB as
end
float(n) would be written in MATLAB as double(n), but it is more likely that you would just make m double precision in which case you could skip doing the float() step.
write(5,*)P,Q,R
would be written in MATLAB as
fprintf('%g %g %g\n', P, Q, R)
Oluwaseyi Aliu
on 10 Apr 2020
Walter Roberson
on 10 Apr 2020
snul = 0.0;
snur = 0.0;
for j = 0:m
rnul = (th(0,j) - th(1,j)) * n;
rnur = (th(n-1,j) - th(n,j)) * n;
snul = snul + rnul;
snur = snur + rnur;
fprintf('%g %g %g\n' j/m, rnul, rnur);
end
avnl = snul / m;
avnr = snur / m;
fprintf('%g %g %g\n', ra, avnl, avnr);
I do not see any 100 x 100 matrices, not unless you are saying that th is a matrix. In fortran it is possible but not all that common to declare arrays to start from index 0, or any other index. I would want to see the statements that defined th, such as
REAL*8 th(100,100)
but it could not be exactly like that if th is a matrix being indexed at 0.
Oluwaseyi Aliu
on 10 Apr 2020
Accepted Answer
More Answers (0)
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!