compare two matrices with isequal
Show older comments
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 ?
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!