How can i plot this 3D function?
3 views (last 30 days)
Show older comments
an Electrical Engineering Student
on 30 Mar 2021
Commented: Star Strider
on 30 Mar 2021
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?
0 Comments
Accepted Answer
Star Strider
on 30 Mar 2021
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 Comments
More Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!