Piecewise 3D plotting
Ältere Kommentare anzeigen
Hi, I need to do a 3D plot of the following functions using piecewise:
y1 = -0.00278018473212*x.^3 + 0.0764514697018*x.^2 + -0.481036946424*x + 4.37885609332;% both need to be in the interval of 4 < x < 14 as well
y2 = 0.0000772436429838*x^3+0.0146583319491*x^2-0.184551271403*x+4.99872818128;% both need to be in the interval of 4 < x < 14 as well
y3 = 4.5 %interval 2.5 < x < 4
y5 = 5.5 %interval 14 < x < 14.5
y6 = 5.0 %interval 14 < x < 14.5
Z = piecewise(2.5 < x < 4 ,y3,4 < x < 14,y2,14 < x < 14.5, y5);
How can I:
1) plot the function correctly
and
2) add 'y1' into the piecewise as it occupies the same interval as y2 (4<x<14)?
Thanks in advance.
5 Kommentare
Moisés Abel
am 5 Sep. 2023
Moisés Abel
am 5 Sep. 2023
I see that you have edited your post a second time, but the revisions you've made are irrelevant to the questions I asked you before.You will have no hope of clarifying the post until you answer them.
So once again: Are you trying to make a surface plot? In a surface plot, Z is a function of two variables Z(x,y). But in your post, Z depends on only one one variable Z(x). So, in what way is Z() to be seen as a function of two variables?
Antworten (1)
Perhaps this is what you meant:
syms Z(x,y)
y1 = -0.00278018473212*x.^3 + 0.0764514697018*x.^2 + -0.481036946424*x + 4.37885609332;% both need to be in the interval of 4 < x < 14 as well
y2 = 0.0000772436429838*x^3+0.0146583319491*x^2-0.184551271403*x+4.99872818128;% both need to be in the interval of 4 < x < 14 as well
Z1(x,y) = piecewise( 2.5 < x & x < 4 , 4.5,...
4 < x & x < 14, y1,...
14 < x & x < 14.5, 5.5 );
Z2(x,y) = piecewise( 2.5 < x & x < 4 , 4.5,...
4 < x & x < 14, y2,...
14 < x & x < 14.5, 5.5 );
fsurf(Z1); hold on; fsurf(Z2); hold off
xlim([2.5 14.5])
ylim([2.5 14.5])
1 Kommentar
Moisés Abel
am 5 Sep. 2023
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
