フィルターのクリア

Unable to perform assignment because the left and right sides have a different number of elements.

1 回表示 (過去 30 日間)
Hi all,
I am trying to divide a line as attached into 3 main increments which each has different thickness (size)
then divide the 3 increments into 3 sub increments
So I would like my the following results
t(i) =[5 10 20]
and my sub_t should be = [0 2.5 5 5 7.5 10 10 15 20 ]
clear all;
clc;
increments=[5 5 10]
t=0
for i=1:3
t(i)=t+increments(i)
%sub_t=linspace(t(i),t(i+1),3) could be
end

採用された回答

Chunru
Chunru 2021 年 8 月 29 日
編集済み: Chunru 2021 年 8 月 29 日
increments=[5 5 10]
increments = 1×3
5 5 10
t0=0;
t = zeros(size(increments));
sub_t = [];
for i=1:3
%t(i)=t+increments(i)
t(i)=t0+increments(i);
sub_t=[ sub_t linspace(t0,t(i),3)];
t0 = t(i);
end
t
t = 1×3
5 10 20
sub_t
sub_t = 1×9
0 2.5000 5.0000 5.0000 7.5000 10.0000 10.0000 15.0000 20.0000
  4 件のコメント
sci hub
sci hub 2021 年 8 月 29 日
Ok for t
but how could I have a vector of sub_t with all the 9 values ??
I tried to add a new loop with 9 but not working
i need my sub_t(i)=[0 2.5 .. 20 ]
Thanks again

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by