How to convert "do loop" of fortran to matlab?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jos (10584)
2016년 5월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!