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:
conditional plot

Subject: conditional plot

From: sr

Date: 5 Apr, 2011 18:23:09

Message: 1 of 5

Hi friends,
I have a matrix with 124821 rows and 6 columns. I would like to plot column 6 versus column 5 when column 4 has certain value.
Im using the following commands to do this.

if find(A(:,4)==6435)
    plot(A(:,6),-A(:,5))
end

but apparently it is plotting all the values of column 6 versus all the values of column 5 with out using my condition.
Can someone help me how to do this.

thanking you in anticipation

cheers

Subject: conditional plot

From: Florin Neacsu

Date: 5 Apr, 2011 18:40:21

Message: 2 of 5

"sr" wrote in message <infmmd$gqf$1@fred.mathworks.com>...
> Hi friends,
> I have a matrix with 124821 rows and 6 columns. I would like to plot column 6 versus column 5 when column 4 has certain value.
> Im using the following commands to do this.
>
> if find(A(:,4)==6435)
> plot(A(:,6),-A(:,5))
> end
>
> but apparently it is plotting all the values of column 6 versus all the values of column 5 with out using my condition.
> Can someone help me how to do this.
>
> thanking you in anticipation
>
> cheers


Hi,

try

ind=A(:,4)==6435;
plot(A(ind,6),A(ind,5))

Regards,
Florin

Subject: conditional plot

From: Corey Scheip

Date: 5 Apr, 2011 18:44:20

Message: 3 of 5

I would do something like this:

ind=find(A(:,4)==6435); % this will give you the rows where (A,4)==6435
plot(A(ind,6),-A(ind,5));

% this way you also don't need a loop, which should speed it up a bit. Best of luck,

Subject: conditional plot

From: sr

Date: 5 Apr, 2011 18:58:05

Message: 4 of 5

"Florin Neacsu" <fneacsu2@gmail.com> wrote in message <infnml$4e3$1@fred.mathworks.com>...
> "sr" wrote in message <infmmd$gqf$1@fred.mathworks.com>...
> > Hi friends,
> > I have a matrix with 124821 rows and 6 columns. I would like to plot column 6 versus column 5 when column 4 has certain value.
> > Im using the following commands to do this.
> >
> > if find(A(:,4)==6435)
> > plot(A(:,6),-A(:,5))
> > end
> >
> > but apparently it is plotting all the values of column 6 versus all the values of column 5 with out using my condition.
> > Can someone help me how to do this.
> >
> > thanking you in anticipation
> >
> > cheers
>
>
> Hi,
>
> try
>
> ind=A(:,4)==6435;
> plot(A(ind,6),A(ind,5))
>
> Regards,
> Florin

Thanks very much Florin. But my 'ind' has several values. Is it possible to plot all of them in the same plot?? or can i use a loop for each ind, plot....

cheers

Subject: conditional plot

From: Florin Neacsu

Date: 5 Apr, 2011 19:04:20

Message: 5 of 5

"sr" wrote in message <infons$mb6$1@fred.mathworks.com>...
> "Florin Neacsu" <fneacsu2@gmail.com> wrote in message <infnml$4e3$1@fred.mathworks.com>...
> > "sr" wrote in message <infmmd$gqf$1@fred.mathworks.com>...
> > > Hi friends,
> > > I have a matrix with 124821 rows and 6 columns. I would like to plot column 6 versus column 5 when column 4 has certain value.
> > > Im using the following commands to do this.
> > >
> > > if find(A(:,4)==6435)
> > > plot(A(:,6),-A(:,5))
> > > end
> > >
> > > but apparently it is plotting all the values of column 6 versus all the values of column 5 with out using my condition.
> > > Can someone help me how to do this.
> > >
> > > thanking you in anticipation
> > >
> > > cheers
> >
> >
> > Hi,
> >
> > try
> >
> > ind=A(:,4)==6435;
> > plot(A(ind,6),A(ind,5))
> >
> > Regards,
> > Florin
>
> Thanks very much Florin. But my 'ind' has several values. Is it possible to plot all of them in the same plot?? or can i use a loop for each ind, plot....
>
> cheers

Hi,

You do not need a for loop to plot. If you are new to Matlab and you have a C background it might take a while to get used to this. Matlab works better with "vectorized" code. Read some tutorials and you will get a handle of it quite fast.

Good luck.
Florin

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