MATLAB Answers

making matrix of matrices of specific inputs

9 views (last 30 days)
Edwin Espin
Edwin Espin on 17 Apr 2021 at 1:03
Commented: Star Strider on 17 Apr 2021 at 14:38
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

Accepted Answer

Star Strider
Star Strider on 17 Apr 2021 at 2:05
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.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!