Borrar filtros
Borrar filtros

Matrix manipulation: update columns from stored variables

1 visualización (últimos 30 días)
ARP
ARP el 17 de Mzo. de 2017
Comentada: Star Strider el 17 de Mzo. de 2017
Suppose I have a set of variables (15) as column vectors, called A from 1-15. Now I would like to make a matrix of all those variables. They have 12501 rows if that helps.
I thought about creating first a zeros matrix (12501,15), and then append each column with my variables.
is there other way to do it? I read about cell2mat but I don't get it. I am truly beginner..
How could I do it in a loop for n variables?
Any help will be very appreciated! Thanks

Respuesta aceptada

Star Strider
Star Strider el 17 de Mzo. de 2017
‘I have a set of variables (15) as column vectors, called A from 1-15’
If they are ‘A1’, ‘A2’, ... ‘A15’, and you only need to do this once, just type it manually:
A_Matrix = [A1 A2 A3 A4 A5 ... A15];
I will let you fill in the others.
Then save it as a ‘.mat’ file so you can simply load it when you need it.
  2 comentarios
ARP
ARP el 17 de Mzo. de 2017
How do I tell to Matlab to count how many variables do I have?
Star Strider
Star Strider el 17 de Mzo. de 2017
I was thinking that if you only had 15 vectors, you could just type them in.
If you want to program it, this will probably work:
N = 15; % Number Of ‘A’ Vectors
A_Matrix = zeros(12501,N);
for k1 = 1:N
A_Matrix(:,k1) = eval(sprintf('A%d',k1));
end
Note This is UNTESTED CODE. It should work.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB 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!

Translated by