How to convert this fplot to 3D plot view

3 次查看(过去 30 天)
syms z
t=0.2;
sc=0.6;
s1=z;
s2=2*(sqrt(t));
x=(s1./s2);
c5=exp((2*x*(sqrt(sc*t))));
c6=erfc((x*sqrt(sc))+(sqrt(t)));
c7=exp((-2*x*(sqrt(t*sc))));
c8=erfc((x*sqrt(sc))-(sqrt(t)));
q=((1/2)*((c5*c6)+(c7*c8)));
xlim([0 5]);
ylim([0 1]);
fplot(z,q)
hold on
legend ("sc=2.01","sc=","sc=0.6");
Warning: Ignoring extra legend entries.
xlabel("η (Similarity parameter)");
ylabel("C (Concentration)");

采纳的回答

Matt J
Matt J 2024-8-6
view(3)
Warning: Ignoring extra legend entries.

更多回答(1 个)

Shishir Reddy
Shishir Reddy 2024-8-6
Hi Dilip
To convert a 2D plot to a 3D mesh, a third variable needs to be introduced. In this case, the variable sc can be considered as third dimension and the mesh plot can be generated for function q against z and sc.
This can be implemented in MATLAB as follows
% Define symbolic variables
syms z sc
t = 0.2;
% Intermediate calculations
s1 = z;
s2 = 2 * (sqrt(t));
x = (s1 ./ s2);
c5 = exp((2 * x * (sqrt(sc * t))));
c6 = erfc((x * sqrt(sc)) + (sqrt(t)));
c7 = exp((-2 * x * (sqrt(t * sc))));
c8 = erfc((x * sqrt(sc)) - (sqrt(t)));
q = ((1 / 2) * ((c5 * c6) + (c7 * c8)));
% Define the range for z and sc
z_range = [0 5];
sc_range = [0.5 2.5]; %these values can be changed as per requirement
% Plot the 3D surface using fsurf with symbolic expression
fsurf(q, [z_range sc_range])
xlabel('z (Similarity parameter)')
ylabel('sc')
zlabel('C (Concentration)')
title('3D Surface Plot of Concentration vs Similarity Parameter and sc')
For more information regarding the ‘fmesh’ function, kindly refer the following documentation https://www.mathworks.com/help/matlab/ref/fmesh.html
I hope this helps.

类别

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