필터 지우기
필터 지우기

help with for statement or looping (Translating fortran 90 to Matlab)

조회 수: 1 (최근 30일)
Matt
Matt 2012년 10월 17일
basically my supervisor uses fortran 90 but im using matlab to analyse so he cant really help me but basically he wants me to do the following.
where N =357 in this case (Fortran 90)
loop i = 0.....N loop j = 0....N
Some function of i and j
end loop end loop
so if the function is as follows
f(x) = x(i) - x(j)
then the loop runs over all of the j terms but keeps i constant then runs again at i=2, i=3 etc etc
my attempt in matlab is as follows;
for i = 357
for j =357
f(x) = x{1}(1:i,1) - x{1}(1:j,1); end end
where x is a 1x1 cell, inside the cell is a 357x3 matrix and i need to read the first row so i = 1. then code runs through j=1:357, then code repeats for i = 2 and again runs through 1:357.
I hope that makes sense if someone can give me a hand that would be cool :)
MC
  댓글 수: 1
Ben Barrowes
Ben Barrowes 2012년 10월 19일
Matt,
I think it would be a lot easier if you just posted a working example of the fortran code you want to translate. The translation and the techniques used to vectorize the translated matlab code will differ depending on the fortran source.
For general conversion of fortran source to matlab source, f2matlab from the mathworks file exchange may help as well.
bb

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by