2017-10-12 156 views
-2
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 

在这段代码中,下面的代码实现了什么?任何人都可以解释这个matlab代码给我吗?

n((m-59))=m; 

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

+0

'N((M-59))= M'意味着分配值'M'在'N'中等于'M-59'值即将60加上等于'm-59'的值。与循环'for m = 60:70'一起,它将'n'中的所有值加1到10之间的60。 – kostek

+0

不是''n'中的值是_equal_'m-59'“,但以'm-59'给出的'n'的_entry_ –

回答

4

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

真的是你能避免使用循环:

n = [60:70]; 
y1 = (14*35)./(n.*9.8); 
y2 = 1-exp((-14*7)./n); 
相关问题