extracting all other variables on a contour level

5 views (last 30 days)
I have a x-y meshgrid with different variables in it. I plot a contour level of f1 using [c,h]=contour(x,y,f1,clev):
Now I need to save other variables like f2,f3,... only on the shown contour level of f1 (blue line) in a matrix.
  3 Comments
Roozbeh Saghatchi
Roozbeh Saghatchi on 21 Jul 2020
Thank you Adam,
x and y position have already calculated in [c,h]=contour(x,y,f1,clev). Now how can I relate it to another function f2(x,y) at those specific x and y values?
Adam Danz
Adam Danz on 21 Jul 2020
The functions I mentioned do not calculate the x,y values. They only reorganize the c or h outputs of contour() by level. For example, using the first one in my list,
% Reorganize the contour outputs into a table.
[cm, h] = contour(x,y,f1,clev);
contourTable = getContourLineCoordinates(cm);
% Look at first few rows of the table (fake data)
% 4×4 table
% Level Group X Y
% ________ _______ _______ _______
% -5.8504 1 0.44266 -1.75
% -5.8504 1 0.375 -1.8038
% -5.8504 1 0.25 -1.8526
% -5.8504 1 0.125 -1.8498
% Get the index for all rows at level #7 (you could also index by group number)
levelIdx = contourTable.Level == h.LevelList(7);
% or
% levelIdx = contourTable.Group == 7;
% Use the x and y values
x(levelIdx)
y(levelIdx)

Sign in to comment.

Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!