Error using +. Matrix dimensions must agree
Show older comments
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.
Answers (1)
John D'Errico
on 16 Sep 2015
Edited: John D'Errico
on 16 Sep 2015
0 votes
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?
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!