If clause – if column blank than

3 visualizaciones (últimos 30 días)
Lui Sa
Lui Sa el 18 de Nov. de 2020
Comentada: Cris LaPierre el 18 de Nov. de 2020
Hello guys,
I am encoutering a probem with a script I am currently working on. The idea is that any row of a column named "Anxiety_RESP" that does not contain a value ([ ]) should be replaced with the corresponding value found in a column named "blackscreen_RESP".
So far, I wrote the following code:
for k=1:height(data_pp)
if data_pp.Anxiety_RESP == [];
data_pp.Anxiety_RESP = data_pp.blackscreen_RESP;
else data_pp.Anxiety_RESP = data_pp.Anxiety_RESP;
end
However, the code does not work and the following error is displayed:
Error using ==
Matrix dimensions must agree.
Error in CorrectScript (line 41)
if data_pp.Anxiety_RESP == [];
Thank you in advance!
Best wishes,
Luisa

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 18 de Nov. de 2020
Try isempty instead of ==[].
  2 comentarios
Lui Sa
Lui Sa el 18 de Nov. de 2020
Thank you very much! Unfortunately, isempty didn't work. It now states the following error:
Error using isempty
Not enough input arguments.
Error in CorrectScript (line 41)
if data_pp.Anxiety_RESP == isempty;
Cris LaPierre
Cris LaPierre el 18 de Nov. de 2020
Well, you do have to use it correctly. I suggest looking at the documentation page I linked to.
if isempty(data_pp.Anxiety_RESP)
We don't know what Ansiety_RESP is. You may need to do this.
for k=1:height(data_pp)
if isempty(data_pp.Anxiety_RESP(k))
...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by