excel if statement to matlab
8 ビュー (過去 30 日間)
表示 古いコメント
hi
so i know there are many efieciant ways to do things on matlab without the need to use the if statement, and I was wondering if someone could help out on converting this excel formula/code to matlab without the need for a double if statements
=IF(AND(E5=0,E4<>0),F4+1,F4)
0 件のコメント
採用された回答
Monika Jaskolka
2021 年 7 月 30 日
編集済み: Monika Jaskolka
2021 年 7 月 30 日
I don't see that a "double if" is necessary:
x = 0;
if (~E5 && E4)
x = F4 + 1;
else
x = F4;
end
If you are asking for a one line conditional assignment like below, Matlab doesn't support this syntax
condition ? true-expression : false-expression
6 件のコメント
Rik
2021 年 8 月 2 日
@Monika Jaskolka Consider teaching yourself to use numel instead of length. It is never a worse option, and it might save you from a difficult bug hiding in your program due to array input (instead of vector inputs).
その他の回答 (0 件)
参考
カテゴリ
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!