Info

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

calling for the same data based on a result

2 visualizaciones (últimos 30 días)
Panda Girl
Panda Girl el 31 de Oct. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
  • data1 = a
  • data2 = b
  • x = a*b;
  • c = a;
  • for i = 0
  • if c > 5
  • c = 1
  • else
  • c = 0
  • end
I want to write a code such that if c = 1 it will take data1. I am trying to write a code but I am getting a confused how to return to data1 if c = 1 is the result
  6 comentarios
Panda Girl
Panda Girl el 31 de Oct. de 2018
yes i did remove then from the statement. isnt it okay if the for loop executes once? I am sorry I didn't understand your point?
Bob Thompson
Bob Thompson el 31 de Oct. de 2018
Editada: Bob Thompson el 31 de Oct. de 2018
I think it's possible for Matlab to execute a for loop only once, it's just redundant because you can just execute the commands once without the loop.
For your if statements your conditions seem to be set up right, I would just replace the count_tag0 = 1 type lines with the execution of your next operation with sc1/sc2/sc0 as an input. Defining count_tag to be 1 is a bit redundant.
if count_tag0 > 8;
result = operation(sc0);
end
if count_tag1 > 8;
result = operation(sc1);
end
if count_tag2 > 8;
result = operation(sc2);
end

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by