Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Chunru
Chunru il 29 Ago 2021
Modificato: Chunru il 29 Ago 2021
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 Commenti
sci hub
sci hub il 29 Ago 2021
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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by