フィルターのクリア

Automatically populating a vector with the output of a for-loop

1 回表示 (過去 30 日間)
Robert Mason
Robert Mason 2016 年 7 月 30 日
編集済み: Azzi Abdelmalek 2016 年 7 月 30 日
I have some initial data and a for-loop that uses this data:
d(1)=-0.3;
q(1)=0.08;
d(2)=0.4+0.1*i;
q(2)=0.11;
s=1;
N = 2;
for j = 1:N;
nd(j) = q(s)/(q(j) + d(j) - d(s)) - q(s)/(q(j) - d(s));
end;
and I would like to populate a vector with the output of the for-loop:
dv=[nd(1)...nd(j)];
however my code for populating the vector, dv=[nd(1)...nd(j)], was a guess and does not seem to be right. What is the correct way to code up a vector which automatically populates itself with the consecutive outputs of a for-loop?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 30 日
編集済み: Azzi Abdelmalek 2016 年 7 月 30 日
nd = q./(q + d - d(s)) - q(s)./(q- d(s))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by