If statement not working
1 回表示 (過去 30 日間)
古いコメントを表示
I have a struct variable that has 20 fields. 11 f them are row matrices of about 24536 x 1 double, while the remaining are either characters, strings and arrays of different dimensions.
i am using if statement to compare the size of each field but it is still giving me some fields that should be omitted.
Code:
b=size(second{1,1}); % second is the cell array and i am using the size of first cell array value
if size(second{i,1}) == b
statements
else
remove field
end
but it is still not removing some of the fields that do not have same dimensions
1 件のコメント
the cyclist
2021 年 5 月 21 日
編集済み: the cyclist
2021 年 5 月 21 日
Can you upload the data (or a small, representative sample) in a MAT file?
Also, in the statement
if size(second{i,1}) == b
what is i? Are you doing this inside a for loop? It would be best if you included a self-contained piece of code that we can run.
回答 (1 件)
Walter Roberson
2021 年 5 月 21 日
編集済み: Walter Roberson
2021 年 5 月 21 日
use isequal to compare items that might not be the same size. That is, for arrays with more than two dimensions size() would not be of length 2.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!