Conditional statement in a for/if loop

2 visualizaciones (últimos 30 días)
Fraje Watson
Fraje Watson el 6 de Jun. de 2019
Comentada: Fraje Watson el 7 de Jun. de 2019
Hi,
I'm trying to write a loop with 5 variables. Here's what I want to do in words, but can't make my code work
for every value of Frame
if LBOS > RBOS
give LDSM
else give RDSM
I'd like the results to be displayed in a table alongside the associated Frame value. I hope that makes sense.
Thanks very much!
  1 comentario
Alex Mcaulley
Alex Mcaulley el 6 de Jun. de 2019
How is your data?
whos Frame
whos LBOS
whos RBOS
whos LDSM
whos RDSM

Iniciar sesión para comentar.

Respuesta aceptada

Alex Mcaulley
Alex Mcaulley el 7 de Jun. de 2019
Try this:
res = RDSM;
res(LBOS > RBOS) = LDSM(LBOS > RBOS);
T2 = table(frame,res);

Más respuestas (1)

Fraje Watson
Fraje Watson el 6 de Jun. de 2019
T = readtable('file.csv');
frame = T{:,1};
LDSM = T{:,2};
RDSM = T{:,3};
LBOS = T{:,4};
RBOS = T{:,5};

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by