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 月 7 日
Perfect - thank you :)

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by