How to fit a curve into contour plot?

28 views (last 30 days)
Hi everyone,
I would like to fit a curve (draw black line) into a contour plot (please refer to the attachment).
Any suggestions?
Thank you,
Carola

Accepted Answer

John D'Errico
John D'Errico on 19 Apr 2022
Edited: John D'Errico on 19 Apr 2022
Sometimes it is easier to just draw the curve yourself. I say this because the curve you drew might not have been the curve I would have chosen. I might have chosen something that goes more through the middle of the contour lines. And that means that your judgement about where you want the curve to be is most important.
Having said that, I would also point out that the AXIS scaling can be a significant factor in all of this. For example, consider the following set of contours:
To me, it clearly looks like the line I would draw here, using the same logic I think you used, that line would be vertical. Right?
In this second contour plot, the line drawn would absolutely be horizontal, correct?
I drew in lines where I think you would draw them in each case.
But, what if I told you the only difference between those two contour plots was the axis scaling?
[X,Y] = meshgrid(-100:100);
contour(X,Y,Z,[1:5:500]);
All I did then was to carefully change the axis scaling, making the same set of PERFECTLY circular contours, now look like they were pointing in one direction or another.
Look carefully at the axes on the two plots.
So are you still ABSOLUTELY positive where that line belongs? If you are, then just draw it by hand. But I would still be asking if you really do know where that curve belongs?
  6 Comments
Torsten
Torsten on 19 Apr 2022
Now use a search to find the maximum value for y, at that specific value of x.
Is it this what is meant by "most energetic part of the signal" ?
Rik
Rik on 20 Apr 2022
Comment posted as flags by @carola forlini:
Thank you for your reply. This comment really helps.
Comment posted as flags by @carola forlini:
Not exactly. What I mean is that the signal presents an interval in which the power is higher. This is the area where I want to fit a curve. Thank you.

Sign in to comment.

More Answers (1)

KSSV
KSSV on 19 Apr 2022
Get the contour line coordinates using the contour function and use polyfit. Read about polyfit.
  1 Comment
Ruya Ulutas
Ruya Ulutas on 17 Feb 2023
How can you combine these together? I have a polyfit and view of a trisurface function.

Sign in to comment.

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!