Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Matt
Matt le 17 Oct 2012
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 commentaire
Ben Barrowes
Ben Barrowes le 19 Oct 2012
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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by