making matrix of matrices of specific inputs
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2021-4-17
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!