How can i plot 3d scatter and equation plot in single figure?

I am generating a 3d scatter plot and 3d surface in seperate figure using following code.
P=[4500 4550 5000 9050 14300 6000 7000 3000 13600 7500 4000 6400 8500 8800 6600 21300 8630 3750];
H=[233.18 211.67 248.18 527.46 486.5 321.81 434.21 153.81 375.9 439 190 273.19 236.2 276.89 299.81 347.25 217.8 427];
C=[255.17 263.23 256.93 212.94 183.08 259.00 250.04 334.08 205.00 255.18 317.29 281.44 256.00 223.07 275.02 214.67 250.32 267.61];
scatter3(P,H,C);
and
P=1000:500:25000;
H=50:15:800;
[P,H]=meshgrid(P,H);
C=exp(8.0467).*P.^(-0.1920).*H.^(-0.1444);
mesh(H,P,C);
how can i merge these to graph together. this is not about curve fitting.
Thank you in advance.

 Accepted Answer

UIse the hold function to plot them on the same axes —
P=[4500 4550 5000 9050 14300 6000 7000 3000 13600 7500 4000 6400 8500 8800 6600 21300 8630 3750];
H=[233.18 211.67 248.18 527.46 486.5 321.81 434.21 153.81 375.9 439 190 273.19 236.2 276.89 299.81 347.25 217.8 427];
C=[255.17 263.23 256.93 212.94 183.08 259.00 250.04 334.08 205.00 255.18 317.29 281.44 256.00 223.07 275.02 214.67 250.32 267.61];
figure
scatter3(P,H,C)
P=1000:500:25000;
H=50:15:800;
[P,H]=meshgrid(P,H);
C=exp(8.0467).*P.^(-0.1920).*H.^(-0.1444);
hold on
mesh(H,P,C)
hold off
The surface should likely be plotted near the points. I have no idea what you are doing, so I cannot correct that. I would need more information to help with it.
.

More Answers (0)

Asked:

on 22 Jul 2022

Commented:

on 25 Jul 2022

Community Treasure Hunt

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

Start Hunting!