If clause – if column blank than

3 vues (au cours des 30 derniers jours)
Lui Sa
Lui Sa le 18 Nov 2020
Commenté : Cris LaPierre le 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by