making matrix of matrices of specific inputs

1 visualización (últimos 30 días)
Edwin Espin
Edwin Espin el 17 de Abr. de 2021
Comentada: Star Strider el 17 de Abr. de 2021
I am trying to iterate and organize the inputs "length" in different matrices, but I am obtaining the same result in each matrix. Please, how can I do a matrix containing matrices with specific elements?
clear
clc
length_x11 = linspace (-0.06541, -0.06541, 10);
length_y21 = linspace (0.2458, 0.2458, 10);
length_x12 = linspace (-0.12, -0.06, 10);
length_y22 = linspace (0, 0, 10);
a = 1;
for a = a + 1
for b = 0:9
i11 = length_x11(a);
j21 = length_y21(a);
i12 = length_x12(a);
j22 = length_y22(a);
matrix{b+1} =[i11 i12; j21 j22];
end
end

Respuesta aceptada

Star Strider
Star Strider el 17 de Abr. de 2021
Try this:
for a = 1:numel(length_x11)
% for b = 0:9
i11 = length_x11(a);
j21 = length_y21(a);
i12 = length_x12(a);
j22 = length_y22(a);
matrix{a} =[i11 i12; j21 j22];
% end
end
matrix{ 1}
matrix{10}
Note that the first, second, and last vectors never change. Only the third vector changes.
  2 comentarios
Edwin Espin
Edwin Espin el 17 de Abr. de 2021
thank you very much for your help
Star Strider
Star Strider el 17 de Abr. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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