How do I change a variable in my workspace?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jewel
el 10 de Jul. de 2018
Comentada: Jewel
el 10 de Jul. de 2018
I am trying to change a matrix located in my workspace. It is originally a 1 x 48 matrix and I am just wondering how to edit the dimensions of the matrix. Thank you!
Attached below is my code:
data = textscan(fileID, '%f%f%f%f%f%f','HeaderLines',6,'CollectOutput','');
fclose(fileID);
X = data{1};
0 comentarios
Respuesta aceptada
James Tursa
el 10 de Jul. de 2018
Editada: James Tursa
el 10 de Jul. de 2018
doc reshape
E.g.,
X = your 1x48 vector
Y = reshape(X,4,12); % <-- reshaped to a 4x12 matrix
Z = Y(:); % <-- reshaped to a column vector
Más respuestas (1)
Steven Lord
el 10 de Jul. de 2018
If you want to change the shape of the array without changing the number of elements, take a look at the reshape function.
If you want to change the number of elements in the array, you'll probably want to use the repmat or repelem functions or the operations of indexing or concatenation.
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices 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!