If clause – if column blank than

3 views (last 30 days)
Lui Sa
Lui Sa on 18 Nov 2020
Commented: Cris LaPierre on 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

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!