Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Plotting in 3D

1 view (last 30 days)
kasim
kasim on 12 Apr 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, I am trying to plot 3 variables in the x,y,z plane in MATLAB.However, I keep getting an error.
I have 3 sets of data,
h = [0.015 0.02 0.025 0.03 0.035 0.04];
Tout = [311.32 317.72 323.94 329.54 334.35 338.42];
Area = [0.72 1.28 2 2.88 3.92 5.12];
How can I get a mesh that shows h on the x axis, Tout on the y axis & Area on the z axis?
Regards
  1 Comment
Cris LaPierre
Cris LaPierre on 12 Apr 2020
There is not enough data. To plot in 3D, you need to know the area for every combination of h and Tout. Therefore, Area needs to be a matrix where the rows correspond to the values of Tout, and the columns correspond to the values of h.
For example, I can see that when h=0.015 and Tout=311.32, Area=0.72. But what is the Area when h=0.015 and Tout=338.42?

Answers (1)

Star Strider
Star Strider on 12 Apr 2020
With your data, this is likely the best you dan do:
h = [0.015 0.02 0.025 0.03 0.035 0.04];
Tout = [311.32 317.72 323.94 329.54 334.35 338.42];
Area = [0.72 1.28 2 2.88 3.92 5.12];
hv = linspace(min(h), max(h), 6);
Toutv = linspace(min(Tout), max(Tout), 8);
[H,T] = ndgrid(hv,Toutv);
A = griddata(h,Tout,Area, H,T, 'nearest');
figure
mesh(H, T, A)
grid on
The vector sizes for ‘hv’ and ‘Toutv’ are arbitrary, so make them whatever lengths you want The 'nearest' method is the only one that will work with your data.
.

This question is closed.

Community Treasure Hunt

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

Start Hunting!