Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

way to use returned valued of a if clause

1 visualización (últimos 30 días)
Salvatore Mazzarino
Salvatore Mazzarino el 9 de Nov. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 9 de Nov. de 2012
what do you mean, give an example
Salvatore Mazzarino
Salvatore Mazzarino el 9 de Nov. de 2012
Editada: Salvatore Mazzarino el 9 de Nov. de 2012
suppose that I have an expression like
setdiff(1:5, [2 3])
and I have to use this expression inside the if clause

Respuestas (1)

José-Luis
José-Luis el 9 de Nov. de 2012
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 comentario
Salvatore Mazzarino
Salvatore Mazzarino el 9 de Nov. de 2012
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

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by