任何人都可以向我解释这个matlab代码吗?

时间:2017-10-12 13:18:22

标签: matlab loops math

for m = 60:70;                     %for m's values in the range of 60<m<70%;
    n((m-59))=m;                   %create an array of m's values and store the array under n
    y1((m-59)) = (14*35)/(m*9.8);  %for m's current value, calculate y1
    y2((m-59)) = 1-exp((-14*7)/m); %for m's current value, calculate y2

在这段代码中,下面的代码是什么?

n((m-59))=m;

任何人都可以向我解释这个吗?

1 个答案:

答案 0 :(得分:4)

这段代码的和平计算循环中的ERRORLEVEL。这个奇怪的索引用于将值分配给n, y1, y2等等:我们从n(1), n(2)开始循环,因此要将结果放入m=60而不是n(1),请使用n(60) }。

真的可以避免使用循环:

n(m-59)