Error using == Matrix dimensions must agree.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Ran Yang
am 10 Apr. 2023
Use ismember instead of == .
[r, c] = find(ismember(data, lookupValue));
2 Kommentare
Ran Yang
am 10 Apr. 2023
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.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!