i have a vector and i want to convert it in to single cell aray.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
A = [12 33 44 55 66]
I want to convert it in cell = { 12, 33,44,55,66}
0 comentarios
Respuestas (2)
Star Strider
el 6 de Jul. de 2022
I am not certain what result you want.
Two options —
A = [12 33 44 55 66]
B = num2cell(A)
B = {A}
.
2 comentarios
Star Strider
el 7 de Jul. de 2022
Try this —
A = [12 33 44 55 66];
B = cellstr(string(A))
Au = unique(A)
Bu = unique(B)
You can use unique with both of these.
I have no idea what ‘count the class’ means.
.
Sanyam
el 6 de Jul. de 2022
Hey @rishika yadav
You can create an empty cell of the size of your vector: x = cell(size(A))
Then itererate over all the elements of your vector and assign them correspondingly to your cell variable
In your example, it code would look like:
for i = 1:size(A,2)
x{i} = A(i)
end
Hope that helps! Thanks!
Ver también
Categorías
Más información sobre Data Type Conversion 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!