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:
selecting elements of a vector

Subject: selecting elements of a vector

From: Jose

Date: 1 May, 2009 17:04:01

Message: 1 of 6

Hi everyone,
I have the next vector:
a=[1 6 2 12 32 58 67 58 23 13 5 25 43 67 42 29 7 -3 4 5 1 2 ]

max(1)g

max(2)g

And I want to store all the numbers except (max(1)-2:max(1)+2) and
(max(2)-2:max(2)+2).

Someone can help me how I can get the vector of the pure noise without
the shape 1(32 58 67 58 23) and shape 2(25 43 67 42 29) gettting only the
noise vector:

an=[1 6 12 13 5 7 -3 4 5 1 2 ]

Thanks in advance,

Jose.

Subject: selecting elements of a vector

From: Matt Fig

Date: 1 May, 2009 17:24:01

Message: 2 of 6

"Jose " <jose.l.vega@gmail.com> wrote in message <gtfa21$bhv$1@fred.mathworks.com>...
> Hi everyone,
> I have the next vector:
> a=[1 6 2 12 32 58 67 58 23 13 5 25 43 67 42 29 7 -3 4 5 1 2 ]
>
> max(1)g
>
> max(2)g
>
> And I want to store all the numbers except (max(1)-2:max(1)+2) and
> (max(2)-2:max(2)+2).
>
> Someone can help me how I can get the vector of the pure noise without
> the shape 1(32 58 67 58 23) and shape 2(25 43 67 42 29) gettting only the
> noise vector:
>
> an=[1 6 12 13 5 7 -3 4 5 1 2 ]
>
> Thanks in advance,
>
> Jose.



What is the point of writing max(1) or max(2)?

Subject: selecting elements of a vector

From: Bruno Luong

Date: 1 May, 2009 17:43:01

Message: 3 of 6

You can use maxk in FEX to select the two largest ekements:
% http://www.mathworks.com/matlabcentral/fileexchange/23576

Next as followed:

a=[1 6 2 12 32 58 67 58 23 13 5 25 43 67 42 29 7 -3 4 5 1 2 ];

[m loc]=maxk(a,2);
noise=true(size(a));
for lmax=loc
    left=max(lmax-2,1);
    right=min(lmax+2,length(a));
    noise(left:right)Ășlse;
end
b=a(noise);

% Bruno

Subject: selecting elements of a vector

From: Bruno Luong

Date: 1 May, 2009 17:49:01

Message: 4 of 6


> noise(left:right)?lse;

The above should read (if you read through TMW buggy newsreader - like me):

> noise(left:right) = false;

Bruno

Subject: selecting elements of a vector

From: Jose

Date: 1 May, 2009 19:00:19

Message: 5 of 6

"Matt Fig" <spamanon@yahoo.com> wrote in message <gtfb7h$rt5$1@fred.mathworks.com>...
> "Jose " <jose.l.vega@gmail.com> wrote in message <gtfa21$bhv$1@fred.mathworks.com>...
> > Hi everyone,
> > I have the next vector:
> > a=[1 6 2 12 32 58 67 58 23 13 5 25 43 67 42 29 7 -3 4 5 1 2 ]
> >
> > max(1)g
> >
> > max(2)g
> >
> > And I want to store all the numbers except (max(1)-2:max(1)+2) and
> > (max(2)-2:max(2)+2).
> >
> > Someone can help me how I can get the vector of the pure noise without
> > the shape 1(32 58 67 58 23) and shape 2(25 43 67 42 29) gettting only the
> > noise vector:
> >
> > an=[1 6 12 13 5 7 -3 4 5 1 2 ]
> >
> > Thanks in advance,
> >
> > Jose.
>
>
>
> What is the point of writing max(1) or max(2)?

Hello Matt, only i want to write down a vector which do not consider
the two shapes, shape1 and shape 2, that it is, forget max(1) and max(2).
Only I want a vector without these shapes, only considering the noise.
Bruno did it, but i have to test his code.
Thanks,
Jose.

Subject: selecting elements of a vector

From: Jose

Date: 2 May, 2009 01:16:01

Message: 6 of 6

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gtfcmd$6tf$1@fred.mathworks.com>...
>
> > noise(left:right)?lse;
>
> The above should read (if you read through TMW buggy newsreader - like me):
>
> > noise(left:right) = false;
>
> Bruno

Thnak you ver much Bruno for your great help!!! It works.

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