How can i plot this 3D function?

1 回表示 (過去 30 日間)
an Electrical Engineering Student
an Electrical Engineering Student 2021 年 3 月 30 日
コメント済み: 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
an Electrical Engineering Student 2021 年 3 月 30 日
Thanks! It worked.
Star Strider
Star Strider 2021 年 3 月 30 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by