How can i plot this 3D function?

조회 수: 3 (최근 30일)
an Electrical Engineering Student
댓글: Star Strider 2021년 3월 30일
I'm trying to plot PA, which is a function of VA and PhA. VA represents a voltage and varies from 188V to 208V; PhA is the phase angle of said voltage and varies from 0 to pi.
VA=188:208;
PhA=0:pi;
[VA,PhA]=meshgrid(VA,PhA);
z=10+1i;
[theta, rho] = cart2pol(real(z), imag(z));
PA=VA.^2*real(z)/rho^2-VA.*208*cos(PhA-0.15+theta)/rho;
surf(VA,PhA,PA)
the function PA yields the following error:
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 '.*'.
And I can't seem to find the mistake. How can i fix it?

채택된 답변

Star Strider
Star Strider 2021년 3월 30일
Change ‘PhA’ to:
PhA=linspace(0,pi,numel(VA));
then, once the ‘PA’ calculation is fully vectorised (so that it uses element-wise operations everywhere), it works:
VA=188:208;
PhA=linspace(0,pi,numel(VA));
[VA,PhA]=meshgrid(VA,PhA);
z=10+1i;
[theta, rho] = cart2pol(real(z), imag(z));
PA=VA.^2*real(z)./rho.^2-VA.*208.*cos(PhA-0.15+theta)./rho;
figure
surf(VA,PhA,PA)
xlabel('VA')
ylabel('PhA')
zlabel('PA')
.
  댓글 수: 2
an Electrical Engineering Student
Thanks! It worked.
Star Strider
Star Strider 2021년 3월 30일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by