I want to surface plot in the attachment. Also see my code.

조회 수: 1 (최근 30일)
Farooq Aamir
Farooq Aamir 2023년 9월 10일
편집: William Rose 2023년 9월 10일
clear all;close all;
a = 1;
b = 2;
c = 2;
B = 3;
t = 1;
m = 0.5;
gamma = 0.8;
alpha = 0.9;
x = 0:0.01:10;
u = c*x.^gamma/gamma + (B*c^3)*(1+m^2)/(1-b*c^2*(1+m^2))*t^alpha/alpha;
u_1 = sqrt((-6*B*m^2*c^2*(1+(b*c^2*(1+m^2))/(1-b*c^2*(1+m^2))))/a)...
*jacobiSN(u,m);
plot(x,u_1);
grid on
figure(2)
surf([x; x], [u_1(1,:); u_1(1,:)], [zeros(size(x)); ones(size(x))])
grid on
  댓글 수: 4
Dyuman Joshi
Dyuman Joshi 2023년 9월 10일
What equations did you use to get the graph using Mathematica?
Farooq Aamir
Farooq Aamir 2023년 9월 10일
I haven't used mathematica yet but in the paper they write that simulations were obtained by utilizing mathematica.

댓글을 달려면 로그인하십시오.

답변 (1개)

William Rose
William Rose 2023년 9월 10일
편집: William Rose 2023년 9월 10일
The code you shared does not generate a dataset like the image you shared, so I am not sure exactly what you are trying to do. The code generates functions u(x) and u1(x), where x=0:.01:10. The your code plots u(x) versus u1(x), which is bascially a parametric plot, analogous to plotting x(t) versus y(t). The plot appears 3D because you plot it at levelz=0 and z=1, and you connect those with surf() so it looks like a ribbon oriented vertically. Your code is below along with the plots it generates. Beneath that, I will show you some code that generates a plot similar to the image you shared.
a = 1;
b = 2;
c = 2;
B = 3;
t = 1;
m = 0.5;
gamma = 0.8;
alpha = 0.9;
x = 0:0.01:10;
u = c*x.^gamma/gamma + (B*c^3)*(1+m^2)/(1-b*c^2*(1+m^2))*t^alpha/alpha;
u_1 = sqrt((-6*B*m^2*c^2*(1+(b*c^2*(1+m^2))/(1-b*c^2*(1+m^2))))/a)...
*jacobiSN(u,m);
plot(x,u_1);
grid on
figure(2)
surf([x; x], [u_1(1,:); u_1(1,:)], [zeros(size(x)); ones(size(x))])
grid on
Now for some code that generates a plot similar to the image you shared:
x=-12:.6:12; y=-12:.6:12;
[X,Y]=meshgrid(x,y);
Z=3*sin(2*pi*X/8+2*pi*Y/20);
surf(X,Y,Z,'FaceColor','m','EdgeColor','k');
xlabel('X'); ylabel('Y'); grid on; view(45,30)
Good luck.
  댓글 수: 6
William Rose
William Rose 2023년 9월 10일
편집: William Rose 2023년 9월 10일
[edit: change best to rest]
You're welcome.
Here is code that adds the rest of the box around the plot, as you requested. I have used a simplified surface example, but you scould use your equation for u_1(x) and get a similar result.
x=0:.2:10; z=-1.5*sin(2*pi*x/4.75);
figure
surf([x;x], [zeros(size(x));ones(size(x))],[z;z],'FaceColor','interp','EdgeColor','none');
hold on;
% add the actual data points
plot3(x,zeros(size(x)),z,'-r.',x,ones(size(x)),z,'-k.');
xlabel('X'); ylabel('Y'); zlabel('Z');
colorbar; view([37.5,30]); grid on; box on
% Now the code for the foreground edges of the box
axLim=[xlim;ylim;zlim]; % get axis limits
%make an array of the vertices needed to draw the box
boxVerts=[[axLim(1,1);axLim(2,1);axLim(3,2)],[axLim(1,2);axLim(2,1);axLim(3,2)],...
[axLim(1,2);axLim(2,1);axLim(3,1)],[axLim(1,2);axLim(2,1);axLim(3,2)],axLim(:,2)];
%draw the foreground edges of the box
plot3(boxVerts(1,:),boxVerts(2,:),boxVerts(3,:),'-k')
If the box were rotated about +-90 or 180 degrees, you would need to adjust the vertex list a bit. Good luck.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by