フィルターのクリア

I would like to save each value which fulfill the condition.

2 ビュー (過去 30 日間)
theintern
theintern 2017 年 10 月 27 日
コメント済み: theintern 2017 年 10 月 27 日
Hello community,
x=7;
while 7<=x<=10
for i=lenght(z)
for j=lenght(y)
Calculate equation A and eq. B, depend y and z
if t<0.5 && k<0.5
Put New values for eq. A and eq. B
break
end
end
end
x=x+1
end
For example, at 1st step x=7, I will calculate 2 values and when they fulfill the conditions, I would like to save the new values and go to x=8 step. Can I see the results at the end (when the all loops are finished) like : x=7 t=0.4, k=0.3 A=27 B=13 x=8... x=9... x=10...
I hope it is clear, if it is not, please inform me to explain more. Thanks in advance!

採用された回答

KSSV
KSSV 2017 年 10 月 27 日
This demo might be useful, for you:
count = 0 ; % initialize a count
iwant = zeros([],2) ; % initialize the required out put
while count ~= 10 % a while loop
x = rand ; y = rand ; % some values
if x < 0.5 && y < 0.5 % a condition to save the result x, y
count = count+1 ; % increment the count
iwant(count,:) = [x y] ; % store values
end
end
  3 件のコメント
theintern
theintern 2017 年 10 月 27 日
Also, can I use table for it? T= table(var1,var2,var3..) but each iteration it sould add new results.
theintern
theintern 2017 年 10 月 27 日
Hello, thank you so much, it works!

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

その他の回答 (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