Conditional statement in a for/if loop

조회 수: 2 (최근 30일)
Fraje Watson
Fraje Watson 2019년 6월 6일
댓글: Fraje Watson 2019년 6월 7일
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
Alex Mcaulley
Alex Mcaulley 2019년 6월 6일
How is your data?
whos Frame
whos LBOS
whos RBOS
whos LDSM
whos RDSM

댓글을 달려면 로그인하십시오.

채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 6월 7일
Try this:
res = RDSM;
res(LBOS > RBOS) = LDSM(LBOS > RBOS);
T2 = table(frame,res);

추가 답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by