Error using * Inner matrix dimensions must agree? It also shows an error for Y, but I can't figure out what it is?

1 回表示 (過去 30 日間)
w = 3;
t = 0:1:8;
Y = (t*sqrt(t.^2+w^2))+((w^2)*log((t+sqrt(t.^2+w^2))/w));
P2 = 1-((w^2)/(t^.2+w^2))*cos(Y)*cos(Y);
plot(t, P2)
The equation that I am trying to plot are highlighted in blue.
Please Help.

採用された回答

James Tursa
James Tursa 2017 年 4 月 21 日
編集済み: James Tursa 2017 年 4 月 21 日
In addition to replacing appropriate * with .* and / with ./ you have an error with a t^.2 instead of a t.^2
w = 3;
t = 0:1:8;
Y = (t.*sqrt(t.^2+w^2))+((w^2)*log((t+sqrt(t.^2+w^2))/w));
P2 = 1-((w^2)./(t.^2+w^2)).*cos(Y).*cos(Y); % <-- corrected
plot(t, P2)

その他の回答 (1 件)

Greg Dionne
Greg Dionne 2017 年 4 月 21 日
It looks like you want to use ".*" instead of "*" and "./" instead of "/".
  1 件のコメント
Blaz Serna
Blaz Serna 2017 年 4 月 21 日
Sorry but I am still receiving the same error. "w" is considered a scalar as well by the way.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by