Error using +. Matrix dimensions must agree

syms t1 t2 t3 t4
t1=-2:1/10:-1;
y1 = t1.^2 + 4*t1 + 4;
t2=-1:1/10:1.5;
y2= 0.16*t2.^2 - 0.48*t2 + 0.36;
t3=-4:1/10:-2;
y3=0*t3;
t4=1.5:1/10:4;
y4=0*t4;
x1 = y1 + y2 + y3 + y4;
Error using +
Matrix dimensions must agree.

Risposte (1)

John D'Errico
John D'Errico il 16 Set 2015
Modificato: John D'Errico il 16 Set 2015
Why do you bother defining t1, t2, t3, t4 as sym initially? You then set them to numeric variables, and do NOTHING with them in any symbolic form.
Regardless, how many elements does the vector t1 contain? t2? t3? t4?
What will MATLAB do if it is told to add together vectors of different lengths? How should it resolve that, in any way other than returning an error?

Community Treasure Hunt

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

Start Hunting!

Translated by