help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to dump plotted points to matrix form from figure window?


From: Ben Abbott
Subject: Re: How to dump plotted points to matrix form from figure window?
Date: Mon, 18 Jan 2010 08:00:12 -0500

On Jan 18, 2010, at 6:42 AM, Guido Walter Pettinari wrote:

> Hello world!
> 
> I have a function that produces a plot. I would like to dump the plotted 
> points in matrix form without having to modify the function itself.
> 
> For example, imagine that my function is:
>> function plot_square ( n )
>>   x = [1:n];
>>  plot ( x, x.*x )
>> endfunction
> and imagine that I cannot modify it. If I run the function I get a figure; 
> how can I dump to a matrix the plotted points (that is x and x.*x) directly 
> from the figure?
> 
> Thanks,
> 
> Guido

Does this do what you want?

        h = findobj (gcf, "type", "line");
        x = get (h, "xdata");
        y = get (h, "ydata");

Ben






reply via email to

[Prev in Thread] Current Thread [Next in Thread]