How do I use elements in a vector to create a number
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Cesar Valencia
el 28 de Sept. de 2020
Comentada: Cesar Valencia
el 28 de Sept. de 2020
If I have a vector with a certain size of elements how can I turn some of those elements into a combined number versus separate numbers in a vector?
3 comentarios
Respuesta aceptada
David Hill
el 28 de Sept. de 2020
Take whatever indexes of the vecture you want to create the number out of say 1:3
x=[1 2 3 4 9 7];
y=num2str(x(1:3));
y=str2double(y(y~=' '));%123
If the size of the numbers will be the same number of digits, you could do it all together and then reshape at the end.
x=[1 2 3 4 9 7];
y=num2str(x);
y=str2num(reshape(y(y~=' '),3,[])');%[123;497]
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!