Hi :)(adsbygoogle = window.adsbygoogle || []).push({});

I need to program several nested 'for' loops which differs only in index of their variables inside.

So I need to convert this:

fori= 1000:-d:0_{1}

forendi= (1000-(d*i_{2}_{1}):-d:0

....end

fori= (1000-(d*i_{n}_{n-1}):-d:0

end

some function containing all index variables like:

b=(i1*A( :,2), i2*A( :,3), ... in*A( :,n))

c=b/a

d=min(c)

if d<e

e=d

end

into some smart one 'for-loop'. The number of for loops is determined by number of vectors, or rather number of columns in matrix "A" specified prior to the loop.

I'm guessing there should be some array trick instead of indexes i1, i2, in. Something like for A(1,: ) :1000:-d:0.

Or should I somehow call function each time?

Thank you so much

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [matlab] How to program unknown number of 'for' loops with i1, i2,iN variables? Or do it smart way

Tags:

Loading...

Similar Threads for matlab program unknown |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB How to program this in Matlab |

MATLAB Does anyone had this plotting problem with MATLAB? |

**Physics Forums | Science Articles, Homework Help, Discussion**