Clear Filters
Clear Filters

How to convert this fplot to 3D plot view

41 views (last 30 days)
Dilip Jose
Dilip Jose on 6 Aug 2024 at 3:40
Commented: Dilip Jose on 7 Aug 2024 at 6:16
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)");

Accepted Answer

Matt J
Matt J on 6 Aug 2024 at 4:19
view(3)
Warning: Ignoring extra legend entries.
  2 Comments
Dilip Jose
Dilip Jose on 6 Aug 2024 at 4:35
Edited: Dilip Jose on 6 Aug 2024 at 4:35
tan q.....is there any possible to view like mesh ?

Sign in to comment.

More Answers (1)

Shishir Reddy
Shishir Reddy on 6 Aug 2024 at 9:50
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.

Community Treasure Hunt

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

Start Hunting!