How can I convert an array to a matrix?
Mostrar comentarios más antiguos
Hi,
I have an array as follow:
A = [127 77 107 148 30];
I want to convert this array as follows:
B = [127 0;77 0;107 0;148 30]
I mean, I want to split A array unequally or equally.
How can I do this?
Thanks.
4 comentarios
James Tursa
el 5 de Abr. de 2023
What is the rule for when to insert a 0?
Abdullah Türk
el 5 de Abr. de 2023
Image Analyst
el 5 de Abr. de 2023
Editada: Image Analyst
el 5 de Abr. de 2023
Are you going to specify the number of columns to put into each row, like
columnsPerRow = [1; 6];
or
columnsPerRow = [1; 4; 2];
??? Otherwise how would we know? Is this your homework? Sounds like it.
Abdullah Türk
el 5 de Abr. de 2023
Respuestas (1)
Something like this ?
A = [127 77 107 148 30];
B = [A(1:end-2).',zeros(numel(A)-2,1);A(end-1:end)]
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!