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



在Maple软件中使用此公式,我能够正确绘制以下绘图

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);

枫树 1 中的 3D 图 枫树 2 中的 3D 图

但是当我想在 MATLAB 中绘制相同的绘图时,使用以下代码,绘图的边缘绘制不正确。

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);

Matlab 1 中的 3D 图 Matlab 2 中的 3D 绘图

这个问题的解决方案是什么?

当我使用网格函数时 我的图表变成了一个圆圈 但应该是方形的 示例代码:

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')

图1

形状不正确: 图2

正确的形状: 图3

最新更新