Info

此问题已关闭。 请重新打开它进行编辑或回答。

Eror Using * Inner matrix dimensions must agreee HELP

1 次查看(过去 30 天)
Hello, here is my inputs
>> t=(0:t:2*pi);
>> y=exp(-0.3*t)*(2*cos(2*t)+4*sin(2*t))
Error using *
Inner matrix dimensions must agree.
the two trig values must be in a parenthesis, i do not understand the error any help would be greatly appreciated.

回答(1 个)

Star Strider
Star Strider 2015-2-28
Don’t you just hate it when your inner matrix dimensions argue? And over such trivial issues! I remember one time when ... But we can save that for a later time.
You need to vectorise your ‘y’ assignment:
t = pi/10;
t=(0:t:2*pi);
y=exp(-0.3*t).*(2*cos(2*t)+4*sin(2*t))
It produces:
y =
Columns 1 through 6
2.0000e+000 3.6122e+000 3.6625e+000 2.4015e+000 502.8544e-003 -1.2485e+000
Columns 7 through 12
-2.2548e+000 -2.2863e+000 -1.4991e+000 -313.8960e-003 779.3223e-003 1.4075e+000
Columns 13 through 18
1.4271e+000 935.7615e-003 195.9428e-003 -486.4751e-003 -878.6170e-003 -890.8659e-003
Columns 19 through 21
-584.1289e-003 -122.3131e-003 303.6716e-003
I created an initial value for ‘t’ that was necessary for the vector ‘t’. Choose the value you want.

Community Treasure Hunt

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

Start Hunting!

Translated by