Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
writing and reading plots - all in memory?

Subject: writing and reading plots - all in memory?

From: Joao

Date: 14 Jan, 2009 11:15:04

Message: 1 of 5

Hi all,

A matlab routine I've been working on is basically a cycle that writes and reads plots, like this:

while i <= n
figure(1)
plot(x,y)
print -dpng graph -r150
I=imread('graph.png');
i=i+1;
end

What this basically does it transform a matlab plot into a matrix, which I need for further analysis. It works.

I'm aware that this is probably the most inneficient way of doing this, since the plot is exported into a file and then read by matlab. I want to make my routine faster, so my question is:

Is there any way to directly (all in memory) transform a matlab plot into a matrix?

Help would be greatly appreciated!

Thank you,
Joao

Subject: writing and reading plots - all in memory?

From: David

Date: 14 Jan, 2009 13:22:02

Message: 2 of 5

"Joao " <joao_amaral@mail.pt> wrote in message <gkkhfo$rru$1@fred.mathworks.com>...
> Hi all,
>
> A matlab routine I've been working on is basically a cycle that writes and reads plots, like this:
>
> while i <= n
> figure(1)
> plot(x,y)
> print -dpng graph -r150
> I=imread('graph.png');
> i=i+1;
> end
>
> What this basically does it transform a matlab plot into a matrix, which I need for further analysis. It works.
>
> I'm aware that this is probably the most inneficient way of doing this, since the plot is exported into a file and then read by matlab. I want to make my routine faster, so my question is:
>
> Is there any way to directly (all in memory) transform a matlab plot into a matrix?
>
> Help would be greatly appreciated!
>
> Thank you,
> Joao

if you are already plotting the data with matlab why don't you just use that data directly?

Subject: writing and reading plots - all in memory?

From: Joao

Date: 14 Jan, 2009 13:57:02

Message: 3 of 5

"David" <dave@bigcompany.com> wrote in message <gkkotq$6b6$1@fred.mathworks.com>...
> "Joao " <joao_amaral@mail.pt> wrote in message <gkkhfo$rru$1@fred.mathworks.com>...
> > Hi all,
> >
> > A matlab routine I've been working on is basically a cycle that writes and reads plots, like this:
> >
> > while i <= n
> > figure(1)
> > plot(x,y)
> > print -dpng graph -r150
> > I=imread('graph.png');
> > i=i+1;
> > end
> >
> > What this basically does it transform a matlab plot into a matrix, which I need for further analysis. It works.
> >
> > I'm aware that this is probably the most inneficient way of doing this, since the plot is exported into a file and then read by matlab. I want to make my routine faster, so my question is:
> >
> > Is there any way to directly (all in memory) transform a matlab plot into a matrix?
> >
> > Help would be greatly appreciated!
> >
> > Thank you,
> > Joao
>
> if you are already plotting the data with matlab why don't you just use that data directly?

I know it doesn't seem to make a lot of sense :)

The code does what it is suposed to do, I just want to make it run a bit faster.

I'm thinking that inside the matlab "plot" command I should be able to access the matrix I need, but where/how?

Cheers.

Subject: writing and reading plots - all in memory?

From: David

Date: 14 Jan, 2009 14:25:03

Message: 4 of 5

"Joao " <joao_amaral@mail.pt> wrote in message <gkkqve$o6j$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gkkotq$6b6$1@fred.mathworks.com>...
> > "Joao " <joao_amaral@mail.pt> wrote in message <gkkhfo$rru$1@fred.mathworks.com>...
> > > Hi all,
> > >
> > > A matlab routine I've been working on is basically a cycle that writes and reads plots, like this:
> > >
> > > while i <= n
> > > figure(1)
> > > plot(x,y)
> > > print -dpng graph -r150
> > > I=imread('graph.png');
> > > i=i+1;
> > > end
> > >
> > > What this basically does it transform a matlab plot into a matrix, which I need for further analysis. It works.
> > >
> > > I'm aware that this is probably the most inneficient way of doing this, since the plot is exported into a file and then read by matlab. I want to make my routine faster, so my question is:
> > >
> > > Is there any way to directly (all in memory) transform a matlab plot into a matrix?
> > >
> > > Help would be greatly appreciated!
> > >
> > > Thank you,
> > > Joao
> >
> > if you are already plotting the data with matlab why don't you just use that data directly?
>
> I know it doesn't seem to make a lot of sense :)
>
> The code does what it is suposed to do, I just want to make it run a bit faster.
>
> I'm thinking that inside the matlab "plot" command I should be able to access the matrix I need, but where/how?
>
> Cheers.

check out getframe and frame2im, while they talk about movies they may do what you need.

Subject: writing and reading plots - all in memory?

From: Joao

Date: 14 Jan, 2009 23:55:04

Message: 5 of 5

"David" <dave@bigcompany.com> wrote in message <gkksjv$jn0$1@fred.mathworks.com>...
> "Joao " <joao_amaral@mail.pt> wrote in message <gkkqve$o6j$1@fred.mathworks.com>...
> > "David" <dave@bigcompany.com> wrote in message <gkkotq$6b6$1@fred.mathworks.com>...
> > > "Joao " <joao_amaral@mail.pt> wrote in message <gkkhfo$rru$1@fred.mathworks.com>...
> > > > Hi all,
> > > >
> > > > A matlab routine I've been working on is basically a cycle that writes and reads plots, like this:
> > > >
> > > > while i <= n
> > > > figure(1)
> > > > plot(x,y)
> > > > print -dpng graph -r150
> > > > I=imread('graph.png');
> > > > i=i+1;
> > > > end
> > > >
> > > > What this basically does it transform a matlab plot into a matrix, which I need for further analysis. It works.
> > > >
> > > > I'm aware that this is probably the most inneficient way of doing this, since the plot is exported into a file and then read by matlab. I want to make my routine faster, so my question is:
> > > >
> > > > Is there any way to directly (all in memory) transform a matlab plot into a matrix?
> > > >
> > > > Help would be greatly appreciated!
> > > >
> > > > Thank you,
> > > > Joao
> > >
> > > if you are already plotting the data with matlab why don't you just use that data directly?
> >
> > I know it doesn't seem to make a lot of sense :)
> >
> > The code does what it is suposed to do, I just want to make it run a bit faster.
> >
> > I'm thinking that inside the matlab "plot" command I should be able to access the matrix I need, but where/how?
> >
> > Cheers.
>
> check out getframe and frame2im, while they talk about movies they may do what you need.

Thanks! I've been working with those two commands and things are working nicely!

The program is running much faster now.

I'm now limited to my physical display resolution, but I'm trying to get around that.

Tags for this Thread

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.

Contact us