フィルターのクリア

operation after every iteration in Nested for loop

2 ビュー (過去 30 日間)
VASUNDHARA V
VASUNDHARA V 2022 年 3 月 3 日
コメント済み: VASUNDHARA V 2022 年 3 月 5 日
for i=1:100
for j=1:20:720
temp1=d2( :, j : j+19 )
temp2=prod(temp1)
end
end
In the above code, i want that after every 20 th column , a prod operation done then i update a value , then it again takes another 20 coumn like that..but it it printing starting from first 20 col to 720 th col and in every iteration it prints the product..i want to perform some operations like prod and then updation after every 20 th iteration...should i use break command as this code is printing whole result

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 3 月 3 日
for i=1:100
for j = 1 : 60
temp1 = d2( :, j * 60 - 59 : j*60 );
temp2(j) = prod(temp1);
end
end
Question: Why are you doing the exact same thing 100 times?
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 3 日
for i=1:100
for j = 1 : 60
temp1 = d2( :, j * 60 - 59 : j*60 );
temp2(:, j) = prod(temp1, 2);
end
This assumes that you want the product of each partial row each time. end
VASUNDHARA V
VASUNDHARA V 2022 年 3 月 5 日
Thankyou sir

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

カテゴリ

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