How can i plot this 3D function?
1 次查看(过去 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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!