How to convert "do loop" of fortran to matlab?
3 views (last 30 days)
Show older comments
Hello all, I am trying to convert the fortran code to matlab. I am stuck on the following loop of fortran
p=20
q=40
Do 10 x=1,p
t(x)= my equation
10 continue
Do 20 y=1,q
s(y)= my another equation
20 continue
To convert this I used following in matlab:
p=20;
q=40;
for x=1:p
t(x)=my equation;
for y=1:q
s(y)=my another equation;
end
end
But I am not sure if this is the correct way of converting this. Please do suggest.
0 Comments
Answers (1)
Jos (10584)
on 19 May 2016
You have converted them to nested for-loops, in which the inner loop is executed multiple times. I think you want two separate loops.
for x=1:p
t(x)=my equation;
end
for y=1:q
s(y)=my another equation;
end
0 Comments
See Also
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!