compare two matrices with isequal
显示 更早的评论
Hi. I need to compare matrices present inside two separate cells (cells 'AAA' and 'BBB').
AAA = importdata("AAA.mat");
BBB = importdata("BBB.mat");
To be precise AAA{1,1} must equal BBB{1,1}, AAA{2,1} must equal BBB{2,1} and so on...
Is it correct to use the isequal command in this way?
AAA = importdata("AAA.mat");
BBB = importdata("BBB.mat");
equal = isequal(AAA,BBB);
Or should I compare the matrices inside a loop as in this case?
AAA = importdata("AAA.mat");
BBB = importdata("BBB.mat");
% FIRST COLUMN
check_1 = {};
check_2 = {};
for K_1_col = 1:height(AAA)
AAA_1_col = AAA{K_1_col,1};
BBB_1_col = BBB{K_1_col,1};
equal_1_col = isequal(AAA_1_col,BBB_1_col);
result = AAA_1_col==BBB_1_col;
check_1 = [check_1;{equal_1_col}];
check_2 = [check_2;{result}];
end
Or are all three ways equivalent ?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!