Hi,
I have a matrix containing both letters and values. Example down below, very similar to the real one i used below. I have a nother vector saved as
M_Punkter = {'B76', 'B80', 'B83'};
My code for evaluating these is:
VAL=1
for i=1:length(M_Punkter)
Lia = ismember(raw{1,1}(:,1),M_Punkter(i));
VAL=VAL+1;
end
I get the error message
??? Error using ==> cell.ismember at 28
Input must be cell arrays of strings.
Error in ==> Bulleranalys_V3_ej_fin at 77
Lia = ismember(raw{1,1}(:,1),M_Punkter(i));
Note, it is not finished. Just testing phase to get the basics right
I understand that I have made something fundamentally wrong and read up on https://se.mathworks.com/help/matlab/ref/double.ismember.html
where they used cell arays. My raw file contains multilevel cell arays. And my results from raw{1,1}(:,1)
ans =
'Mätpunkt'
[NaN]
'B76'
'B76'
'B76'
'B76'
'B76'
'B76'
'B76'
'B76'
'B76'
[NaN]
[NaN]
[NaN]
and
M_Punkter(i)
ans =
'B76'
I used the example in https://se.mathworks.com/help/matlab/ref/double.ismember.html
A = {'dog','cat','fish','horse'};
Create a cell array of character vectors, B, where some of the vectors have trailing white space.
B = {'dog ','cat','fish ','horse'};
Determine which character vectors of A are also in B.
[Lia,Locb] = ismember(A,B)
Lia = 1×4 logical array
0 1 0 1
Locb = 1×4
0 2 0 4
What key detail have I missed?
Best Answer