简体   繁体   English

如何解决我在 MATLAB 中绘制 plot 的问题?

[英]How to solve my problem to drawing plot in MATLAB?

Using this formula in Maple software, I was able to draw the following plot correctly在 Maple 软件中使用此公式,我能够正确绘制以下 plot

u(r,theta):=-1/4 r^2+0.2866749079-2.78 10^(-11) r^40 cos(40 theta)-8.064151950 10^(-11) r^36 cos(36 theta)-4.943347436 10^(-10) r^32 cos(32 theta)-4.390774680 10^(-9) r^28 cos(28 theta)-4.536478572 10^(-8) r^24 cos(24 theta)-4.832799212 10^(-7) r^20 cos(20 theta)-0.000005529796642 r^16 cos(16 theta)-0.00007085150960 r^12 cos(12 theta)-0.001134817408 r^8 cos(8 theta)-0.03546317566 r^4 cos(4 theta);

x(r,theta):=r*cos(theta);
y(r,theta):=r*sin(theta);

#super ellips function
r0 := 1/(cos(theta)^4+(sin(theta))^4)^(1/4);
plot3d([x(r,theta),y(r,theta),u(r,theta)],r=0..r0,theta=0..2*Pi);

3d plot in Maple 1 3d plot in Maple 2 3d plot 在 Maple 1 3d Z32FA6E1B78A9D4028953E60564A2AA4 在 Maple

But when I want to draw the same plot in MATLAB, using the following code, the edges of the plot are not drawn correctly.但是当我想在 MATLAB 中绘制相同的 plot 时,使用以下代码,plot 的边缘未正确绘制。

clc;clear all;close all;
theta = linspace(0,2*pi,201);
rho=(cos(theta) .^ 4 + sin(theta) .^ 4) .^ (-0.1e1 / 0.4e1)
r=0:0.005:rho;

[TH,R] = meshgrid(theta,r);
X = R .* cos(TH);
Y = R .* sin(TH);

U = -R .^ 2 / 0.4e1 + 0.2866749079e0 - 0.2780000000e-10 .* R .^ 40 .* cos((40 .* TH)) -...
0.8064151950e-10 .* R .^ 36 .* cos((36 .* TH)) - 0.4943347436e-9 .* R .^ 32 .* cos((32 .* TH)) -...
0.4390774680e-8 .* R .^ 28 .* cos((28 .* TH)) - 0.4536478572e-7 .* R .^ 24 .* cos((24 .* TH)) -...
0.4832799212e-6 .* R .^ 20 .* cos((20 .* TH)) - 0.5529796642e-5 .* R .^ 16 .* cos((16 .* TH)) -...
0.7085150960e-4 .* R .^ 12 .* cos((12 .* TH)) - 0.1134817408e-2 .* R .^ 8 .* cos((8 .* TH)) -...
0.3546317566e-1 .* R .^ 4 .* cos((4 .* TH));

mesh(X,Y,U);

3d plot in Matlab 1 3d plot in Matlab 2 3d plot in Matlab 1 3d plot in Matlab 2

What is the solution to this problem?这个问题的解决方案是什么?

When I use the meshgrid function My chart turns into a circle But should be square sample code:当我使用meshgrid function 我的图表变成了圆形但应该是方形示例代码:

theta = linspace(-pi/2,pi/2,100);
phi = linspace(0,2*pi,100);

r = 1+sin(theta*3).*cos(phi*2);

subplot(1,2,1);
polarplot(r);
title('without using meshgrid')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[TH,PHI] = meshgrid(linspace(-pi/2,pi/2,100),linspace(0,2*pi,100));

R = 1+sin(TH*3).*cos(PHI*2);

subplot(1,2,2);
polarplot(R);
title('with using meshgrid')

Picture1图片1

Incorrect shape: Picture2不正确的形状:图2

The correct shape: Picture3正确的形状:图3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM