Thread Subject: Plot to a figure from a function

Subject: Plot to a figure from a function

From: David Doria

Date: 29 Sep, 2007 20:28:13

Message: 1 of 2

in my script i do

h = figure;

then i have a loop which calls a function 'MyFunction' with

MyFunction(h(1), more_params)

the function definition for MyFunction is

function MyFunction(h, more_params)

inside MyFunction, i do

plot(h, ones(10))

and nothing(!) happens until after the program finishes
running, at which point i get a blank axis displayed

does it not work like this?

Thanks,

David

Subject: Plot to a figure from a function

From: Rick Rosson

Date: 29 Sep, 2007 21:03:42

Message: 2 of 2

Hi David,

The plot function expects an axes handle, not a figure handle. Try the
following:

   f = figure;
   a = axes;

   MyFunction(a, ...);

Inside the function:

    plot(a, ... );

I hope that helps.

Thanks.

Rick




"David Doria" <daviddoria@gmail.com> wrote in message
news:fdmcgt$1cj$1@fred.mathworks.com...
> in my script i do
>
> h = figure;
>
> then i have a loop which calls a function 'MyFunction' with
>
> MyFunction(h(1), more_params)
>
> the function definition for MyFunction is
>
> function MyFunction(h, more_params)
>
> inside MyFunction, i do
>
> plot(h, ones(10))
>
> and nothing(!) happens until after the program finishes
> running, at which point i get a blank axis displayed
>
> does it not work like this?
>
> Thanks,
>
> David

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com