How can i plot this 3D function?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
an Electrical Engineering Student
el 30 de Mzo. de 2021
Comentada: Star Strider
el 30 de Mzo. de 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 comentarios
Respuesta aceptada
Star Strider
el 30 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!