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 "/".

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by