Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Chunru
Chunru le 29 Août 2021
Modifié(e) : Chunru le 29 Août 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 commentaires
sci hub
sci hub le 29 Août 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by