Error ~= Invalid types for comparison

4 vues (au cours des 30 derniers jours)
Luca
Luca le 17 Avr 2021
Commenté : Luca le 17 Avr 2021
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 commentaires
Jan
Jan le 17 Avr 2021
You mention, that ID is a categrical variable, but what is "lagmatrix"? Please post a small example of your inputs.
Luca
Luca le 17 Avr 2021
So it looks like this
ID lagmatrix(ID,1)
10000 NaN
10000 1
10000 1
.
.
.
10000 1
10001 1
10001 2
The lagmatrix command moves the original Matrix down by 1 row. So the switch happens one row later.
There where it is not equal I want that the retrurns are NaN.
I realised that it creates you a variable of type double.
I guess this is the problem.
Thank you very much for your help.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by