필터 지우기
필터 지우기

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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by