Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to extract data points from a plot (can't use 'ginput')
Replies: 6   Last Post: Jan 31, 2013 5:26 AM

 Messages: [ Previous | Next ]
 Walter Roberson Posts: 7,678 Registered: 1/20/06
Re: How to extract data points from a plot (can't use 'ginput')
Posted: Aug 25, 2008 12:05 PM

Forrest wrote:

> I'm not very familiar with 'findobj'. Can you walk me
> through how to do this.

lines = findobj(gcf, 'Type', 'line');
nlines = length(lines);
coordscell = cell(nlines,2);
for K=1:nlines
thisline = lines(K);
coordscell{K,1} = get(thisline, 'XData');
coordscell{K,2} = get(thisline, 'YData');
end

If you are lucky, afterwards coordscell will only have 1 x 2 entries,
a single X and Y pair. If not, then you will have to figure out -which-
of the lines is the relevant one for your purposes. *Usually* lines
that Matlab draws for background purposes (e.g., grid lines) will be
hidden objects, but not always.

I can't show you the process from start to finish or test this in
advance as psd() does not take simple waveforms and produce a plot;
it takes a spectrum object class as input and returns something
in a different class that has to be plotted by some other function
(but I couldn't immediately see what the actual plot routine was.)

--
Q = quotation(rand);
if isempty(Q); error('Quotation server filesystem problems')
else sprintf('%s',Q), end

Date Subject Author
8/25/08 Forrest
8/25/08 Steven Lord
8/25/08 Forrest
8/25/08 Steven Lord
8/25/08 Forrest
1/31/13 Ansuman Mahapatra
8/25/08 Walter Roberson