Area in 3-D temperature plot

Hello,
I have a set of oceanographic data with longitude, depth, and temperature. I've used contour3 to make a 3-D image of the data. Now I would like to find the area within the 6-8 deg C temperature range. Is there any way to do this withing Matlab? This is the code I've been using. Thank you!
load 'upcast';
lat = upcast(:,2);
long = upcast(:,3);
depth = upcast(:,4);
temp= upcast(:,5)
x = (upcast(:,3)); %long
y = (upcast(:,4)); %depth
z = (upcast(:,5)); %temp
xv = linspace(min(x),max(x));
yv = linspace(min(y),max(y));
[X,Y] = meshgrid(xv,yv);
Z = griddata(x,y,z,X,Y);
figure
contour3(X,Y,Z);
hold on
surf(X,Y,Z);
axis ij;
ylim ([0 100]);
colorbar
colormap 'jet'
grid off

 采纳的回答

Star Strider
Star Strider 2020-5-20

0 个投票

Apparently, the contour3 call plots temperature contours as a function of longitude and depth. You can specify the levels at which you want the contours to be drawn: Contours at Specific Levels with Labels and also do that in a separate contour call if necessary to get only those specific levels.
The first output ‘M’ is the contour (x,y) coordinates (that here would be longitude and depth, see: M for details) that you can then use with trapz to get the areas.

6 个评论

Thank you! I just tried this and it seems to be working! When I'm using M and trapz the output gives me a lot of numbers. Is there a way to just get one value for the area instead of a whole bunch?
As always, my pleasure!
The ‘M’ matrix should be (2xN) for each contour, with the contours specified as elements of a vector in the contour call. I have no idea what ‘a lot of numbers’ means, since trapz should produce one number for each set of (x,y) vectors for each specific contour, and should be the situation where the contours are continuous.
I am guessing that the and contours are in some way concentric, and you are calculating the areas of each, and then processing (probably subtracting) those data to get the result you want.
It would likely help to have the ‘M’ output, and a description of what you want to do with the vectors it contains.
Yes, I'm looking at a temperature profile of oceanographic data and trying to determine the area of a pool of cold water. The 6 and 8 deg contours are circular and in the middle of the plot surrounded by countours that are higher.
If the contours are continuous (so that there is only one contour for each termperature), this will likely work:
M = contour(X,Y,Z,[6 8]);
T6I = find(M(1,:) == 6); % 6° Start Index
T6L = M(2,T6I); % 6° Column Length
T8I = find(M(1,:) == 8); % 8° Start Index
T8L = M(2,T8I); % 8° Column Length
T6idxrng = T6I+1:T6I+1+T6L;
T6x = M(1,T6idxrng);
T6y = M(2,T6idxrng);
T8idxrng = T8I+1:T8I+1+T8L;
T8x = M(1,T8idxrng);
T8y = M(2,T8idxrng);
Then use trapz as:
T6Area = trapz(T6x, T6y);
T8Area = trapz(T8x, T8y);
and go from there with whatever other processing you want to do with them.
Seems to be working! Thank you so much!
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by