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.

回答 (1 件)

John D'Errico
John D'Errico 2015 年 9 月 16 日
編集済み: John D'Errico 2015 年 9 月 16 日

0 投票

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?

カテゴリ

タグ

質問済み:

2015 年 9 月 16 日

編集済み:

2015 年 9 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by