Error using == Matrix dimensions must agree.

조회 수: 1 (최근 30일)
Aiman Zara
Aiman Zara 2023년 4월 10일
댓글: Ran Yang 2023년 4월 10일
using this code to find the location of each element in the matrix
fn = 'FinalBookExcel.csv';
data = readmatrix(fn); % read the numeric matrix
lookupValue = 'Alternaria Leafspot'; % for example, find the location of all elements with value Alternaria Leafspot
[r, c] = find(data==lookupValue); % return row and column indices
But the following error appear after running this code
Error using ==
Matrix dimensions must agree.
Error in CSV (line 25)
[r, c] = find(data==lookupValue); % return row and column indices
Help me resolve this issue

답변 (1개)

Ran Yang
Ran Yang 2023년 4월 10일
Use ismember instead of == .
[r, c] = find(ismember(data, lookupValue));
  댓글 수: 2
Aiman Zara
Aiman Zara 2023년 4월 10일
@Ran Yang used this but it didnot give me any output( resulted blank)
Ran Yang
Ran Yang 2023년 4월 10일
Are you sure that your csv includes the exact phrase you're looking for?
Are you sure that it was imported correctly into Matlab? If you think you have text but only imported NaNs, see this answer to import as char and not numeric.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by