making matrix of matrices of specific inputs
1 view (last 30 days)
Show older comments
Edwin Espin
on 17 Apr 2021
Commented: Star Strider
on 17 Apr 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
0 Comments
Accepted Answer
Star Strider
on 17 Apr 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 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!