If clause – if column blank than

3 次查看(过去 30 天)
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

采纳的回答

Cris LaPierre
Cris LaPierre 2020-11-18
Try isempty instead of ==[].
  2 个评论
Lui Sa
Lui Sa 2020-11-18
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 2020-11-18
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))
...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by