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