フィルターのクリア

how we can store each and every value in nested for loop.

4 ビュー (過去 30 日間)
Sun Heat
Sun Heat 2018 年 10 月 5 日
編集済み: KALYAN ACHARJYA 2018 年 10 月 5 日
d=linspace(2,4,3);
for t=1:length(d)
c(t)=d(t)^2;
PL=linspace(0.8,1,3);
for q=1:length(PL)
c1(q,t)=PL(q)^2;
N=linspace(11,13,3);
for y=1:length(N)
c2(y,q)=N(y)^2;
end
end
end

採用された回答

KSSV
KSSV 2018 年 10 月 5 日
d=linspace(2,4,3);
c = zeros([],[]) ;
c1 = zeros([],[]) ;
c2 = zeros([],[],[]) ;
for t=1:length(d)
c(t)=d(t)^2;
PL=linspace(0.8,1,3);
for q=1:length(PL)
c1(q,t)=PL(q)^2;
N=linspace(11,13,3);
for y=1:length(N)
c2(y,t,q)=N(y)^2;
end
end
end

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 5 日
編集済み: KALYAN ACHARJYA 2018 年 10 月 5 日
Here already value stored in each iteration
d=linspace(2,4,3);
PL=linspace(0.8,1,3);
N=linspace(11,13,3);
for t=1:length(d)
c(t)=d(t)^2;
for q=1:length(PL)
c1(q,t)=PL(q)^2;
for y=1:length(N)
c2(y,q)=N(y)^2;
end
end
end
Check result in command window: >> c
c =
4 9 16
>> c1
c1 =
0.6400 0.6400 0.6400
0.8100 0.8100 0.8100
1.0000 1.0000 1.0000
>> c2
c2 =
121 121 121
144 144 144
169 169 169
>>
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 5 日
編集済み: KALYAN ACHARJYA 2018 年 10 月 5 日
For example
when t=1 c(1)=2^2=4
when t=2 c(2)=3^2=9
when t=3 c(3)=4^2=16
Please note you have used
linspace(2,4,3)
ans =
2 3 4

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by