If statement for cells

10 ビュー (過去 30 日間)
MarshallSc
MarshallSc 2021 年 7 月 11 日
コメント済み: Star Strider 2021 年 7 月 12 日
Hi, I have 3 different cell arrays like below - same size (let's call them A, B and C):
That I need to evaluate in an if statement in a for loop. But the final result gives me several empty numeric array in couple of the cells. The code is:
for i=1:4
for j=1:4
for k=1:10
for r=1:10
if ((abs(A{i,j}(k,r)))/(abs(C{i,j}(k,r)))<1) && ((abs(A{i,j}(k,r)))/(abs(B{i,j}(k,r)))<1)
A_num{i,j}{k,r}='Point is stable: Category 1 is assigned';
elseif ((abs(A{i,j}(k,r)))/(abs(C{i,j}(k,r)))>1) && ((abs(A{i,j}(k,r)))/(abs(B{i,j}(k,r)))>1)
A_num{i,j}{k,r}='Point is unstable';
end
end
end
end
end
For example, one of the cell array result is like bleow:
I checked all the components of the original cell arrays and none of them are zero or inf. Am I doing something wrong here?

採用された回答

Star Strider
Star Strider 2021 年 7 月 11 日
The && are ‘short circuit’ AND operators. The second expression (after the &&) will not be evaluated if the first expression is false.
If you want to evaluate both of them, just use & instead.
.
  10 件のコメント
MarshallSc
MarshallSc 2021 年 7 月 12 日
Thank you so much buddy. This is an interesting testing method that I will use. Thank you again!
Star Strider
Star Strider 2021 年 7 月 12 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by