If clause – if column blank than

3 visualizzazioni (ultimi 30 giorni)
Lui Sa
Lui Sa il 18 Nov 2020
Commentato: Cris LaPierre il 18 Nov 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

Risposta accettata

Cris LaPierre
Cris LaPierre il 18 Nov 2020
Try isempty instead of ==[].
  2 Commenti
Lui Sa
Lui Sa il 18 Nov 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 il 18 Nov 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))
...

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by