Error ~= Invalid types for comparison
显示 更早的评论
Hi,
I tried to run this code:
D2sub1.RETsm(D2sub1.ID ~= lagmatrix(D2sub1.ID, 1)) = NaN;
and get the error
Error using ~= (line 30)
Invalid types for comparison.
ID is a categorical column.
Is it not possible to compare categorical variables like this?
Thanks,
4 个评论
One can certainly use the ~= operator on categorical variables:
C = categorical([1 2 3]);
D = categorical({'a','b','3'});
C ~= D
Perhaps you could upload your data in a MAT file, so that we can see what is happening in your case?
Jan
2021-4-17
You mention, that ID is a categrical variable, but what is "lagmatrix"? Please post a small example of your inputs.
Luca
2021-4-17
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!