MATRIX DIMENSIONS MUST AGREE error while input strings/char

for i = 1:x
for j = 1:y
if (A{i} ~= B{j})
temp{idx} = B{j};
i = (idx + 1);
end
end
end
A{i} is an array filled with chars
B{j} is also an array filed with chars
When running the program, it won't compare at if (A{i} ~= B{j}) and gives the MATRIX DIMENSIONS MUST AGREE error.
How can I fix this?

답변 (1개)

Alex Mcaulley
Alex Mcaulley 2019년 2월 26일

0 개 추천

Use ~strcmp(A{i},B{j}) instead of A{i} ~= B{j}

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

답변:

2019년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by