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

1 次查看(过去 30 天)
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