Linspace function in for loop
6 ビュー (過去 30 日間)
古いコメントを表示
delta_l_2 = 1; % change in length of tendon 1 and tendon 2 (assume to be the same)
length_1_range = 10:-delta_l_2:5;
length_2_range = 20:delta_l_2:25;
[~,n] = size(length_1_range);
length_1 = zeros(100,n);
length_2 = zeros(100,n);
for i = 1:n
length_1(i) = linspace(0,length_1_range(i),100)'; % length of tendon 1
for j = 1:n
length_2(j) = linspace(0,length_2_range(j),100)'; % length of tendon 2
end
end
I want to create arrays for length 1 and length 2 with values range from 0 to each value in length_1_range and length_2_range but it came out errrors when I run it. May I ask how to correct this code? Thank you!
0 件のコメント
採用された回答
Star Strider
2022 年 7 月 16 日
Try this —
delta_l_2 = 1; % change in length of tendon 1 and tendon 2 (assume to be the same)
length_1_range = 10:-delta_l_2:5;
length_2_range = 20:delta_l_2:25;
[~,n] = size(length_1_range);
length_1 = zeros(n,100);
length_2 = zeros(n,100);
for i = 1:n
length_1(i,:) = linspace(0,length_1_range(i),100)'; % length of tendon 1
for j = 1:n
length_2(j,:) = linspace(0,length_2_range(j),100)'; % length of tendon 2
end
end
length_1
length_2
.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!