w1=104; s=0.3; u=1;
>> w2=w1*(1-(s^2))^(1/2)
w2 =
99.2097
>> y=(s)/(1-(s^2))
y =
0.3297
>> t=linspace(0,0.2,100);
>> x=u*(1-exp(-s*w1*t)*(cos(w2*t)-y*sin(w2*t)));
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the
number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
This is the equation I am trying to input:
x(t)=u[1-e^(-sw1t)*(cos(w2t)-ysin(w2t))]
What is the correct equation for x?

 採用された回答

Ollie A
Ollie A 2019 年 1 月 30 日

0 投票

You have a variable t in your equation which is a vector. In order to multiply vectors in MATLAB you must use the syntax .*. In your case, the equation should be:
x=u*(1-exp(-s*w1*t).*(cos(w2*t)-y*sin(w2*t)));
I believe that should fix it.

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 1 月 30 日

0 投票

x=u*(1-exp(-s*w1*t).*(cos(w2*t)-y*sin(w2*t)));
Jim Riggs
Jim Riggs 2019 年 1 月 30 日
編集済み: Jim Riggs 2019 年 1 月 30 日

0 投票

Variable t is a vector. If you want to perform element-wise multiplication on t, use .* in stead of *
try
x=u.*(1-exp(-s.*w1.*t).*(cos(w2.*t)-y.*sin(w2.*t)));

カテゴリ

ヘルプ センター および File ExchangeMathematics and Optimization についてさらに検索

タグ

質問済み:

2019 年 1 月 30 日

編集済み:

2019 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by