[英]Can anyone explain this matlab code to me?
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;
任何人都可以向我解釋這一點嗎?
這個和平的代碼在循環中計算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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.