Define a series of matrices

9 visualizaciones (últimos 30 días)
Mou Ab
Mou Ab el 21 de Mzo. de 2020
Comentada: Walter Roberson el 21 de Mzo. de 2020
How do I define the next series of matrices
A=[0,1;sigma,0].
where
sigma=[-5:0.01:-4]
And I want the label to be as follows
A1=[0,1;sigma(1),0]

Respuesta aceptada

Stephen23
Stephen23 el 21 de Mzo. de 2020
Editada: Stephen23 el 21 de Mzo. de 2020
Using numbered variables is not going to be neat or efficient. The MATLAB approach would be to use one array, e.g.:
sigma = -5:0.01:-4; % the square brackets are superfluous
N = numel(sigma);
A = [zeros(N,1),ones(N,1),sigma(:),zeros(N,1)]
Each row of A is one of your output vectors, e.g.:
A(1,:)
  2 comentarios
Mou Ab
Mou Ab el 21 de Mzo. de 2020
but we get a vector not a matrix
Walter Roberson
Walter Roberson el 21 de Mzo. de 2020
sigma = -5:0.01:-4; % the square brackets are superfluous
N = numel(sigma);
A = [zeros(1,1,N),ones(1,1,N); reshape(sigma,1,1,N), zeros(1,1,N)];
A is now a 2 x 2 x 101 array. A(:,:,37) would correspond to what you were hoping to see as a separate variable A37

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by