How to fit a curve into contour plot?

15 views (last 30 days)
carola forlini
carola forlini on 19 Apr 2022
Commented: Rik on 20 Apr 2022
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,

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);
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?
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 on 19 Apr 2022
Get the contour line coordinates using the contour function and use polyfit. Read about polyfit.

Community Treasure Hunt

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

Start Hunting!