Info

此问题已关闭。 请重新打开它进行编辑或回答。

Plotting in 3D

1 次查看(过去 30 天)
kasim
kasim 2020-4-12
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Cris LaPierre
Cris LaPierre 2020-4-12
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?

回答(1 个)

Star Strider
Star Strider 2020-4-12
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.
.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by