containers.Map: The number of keys and values must be the same
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mehdi Jaiem
el 6 de Mayo de 2022
Comentada: Walter Roberson
el 7 de Mayo de 2022
I have the above mentioned issue when I try to run this code:
keys = [DS.UserNum];
valueSet = [DS.CarNum];
M = containers.Map(keys,valueSet)
UserNum Car Num
1 [123,257,345,235,553]
2 834
3 [111,156]
4 [111,445,642,164]
5 []
--> The number of keys and values must be the same. How can I correct that.
0 comentarios
Respuesta aceptada
Walter Roberson
el 6 de Mayo de 2022
valueSet = {DS.CarNum};
2 comentarios
Walter Roberson
el 7 de Mayo de 2022
In that example, the keys are character vectors, and the values are scalar numeric. Character vectors are collections of characters.
In your code, the keys are scalar numeric, and the values are vectors of numeric — collections of numbers.
In both cases, collections use {} and scalars use []
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!