Info

この質問は閉じられています。 編集または回答するには再度開いてください。

way to use returned valued of a if clause

1 回表示 (過去 30 日間)
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 11 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have an if clause
if expression
do-something
end
I would use the value return by
expression
into the if clause. Does it exist a way to do this?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 9 日
what do you mean, give an example
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 11 月 9 日
編集済み: Salvatore Mazzarino 2012 年 11 月 9 日
suppose that I have an expression like
setdiff(1:5, [2 3])
and I have to use this expression inside the if clause

回答 (1 件)

José-Luis
José-Luis 2012 年 11 月 9 日
I assume you mean something like, in C/C++ style
if (++i == some_value){
//do something with the new value of i
}
Then, no, I don't think you can do that.
But you can always do
your_val = expression
if your_val == something %some condition
%some operation on your_val
end
  1 件のコメント
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 11 月 9 日
yes exactly what I mean. I come from C so I used to do in that way. ok i will do how you have suggested me

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by