error using contains function

3 visualizaciones (últimos 30 días)
AMINE EL MOUATAMID
AMINE EL MOUATAMID el 22 de Abr. de 2019
Comentada: AMINE EL MOUATAMID el 22 de Abr. de 2019
when I use contains function in a loop it show me that error message, even though Raw is a cell array, and also the compilation complete and the code after if contains(Raw(i,2),serie)==1 works well.
is there a solution for that ?
  5 comentarios
Matt J
Matt J el 22 de Abr. de 2019
Editada: Matt J el 22 de Abr. de 2019
You need to provide the variables (in a .mat file) that would let us run the important section of the code as follows:
load yourMATFile.mat
sizeRaw=size(Raw);
for i=2 : sizeRaw(1,1)
if contains(Raw(i,2),serie)==1
for j=2 : rowRMS(1,1)
if contains(Raw(i,1),RMS(j,1))==1
if contains(Raw(i+1,8),MeasTypeID)==1
Raw(i+1,9)=RMS(j,2);
else
if contains(Raw(i+2,8),MeasTypeID)==1
Raw(i+2,9)=RMS(j,2);
else
if contains(Raw(i+3,8),MeasTypeID)==1
Raw(i+3,9)=RMS(j,2);
end
end
end
end
end
end
end
AMINE EL MOUATAMID
AMINE EL MOUATAMID el 22 de Abr. de 2019
these are the files

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 22 de Abr. de 2019
Editada: Adam Danz el 22 de Abr. de 2019
I can see in your screen shot of workspace variables that your "Raw" array contains mostly NaN values.
According to your error message, the first argument of contains() must be a string array, char vector, or cell array of char vectors. "Raw" appears to be a cell array with lots of NaNs.
You probably want to just skip iterations where the input to contains() includes NaN values (or you might want to use a different method).
  5 comentarios
Adam Danz
Adam Danz el 22 de Abr. de 2019
Editada: Adam Danz el 22 de Abr. de 2019
You need to do some exploring. Some trial and error. The error message tells you that the input to isnan() does not accept cell arrays. So try this
isnan(out{2,2})
% or
isnan([out{2,2}])
More more information on how to work with cell arrays:
AMINE EL MOUATAMID
AMINE EL MOUATAMID el 22 de Abr. de 2019
thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by