How to convert "do loop" of fortran to matlab?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jos (10584)
il 19 Mag 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 Commenti
Vedere anche
Categorie
Scopri di più su Fortran with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!