Thread Subject: array question

Subject: array question

From: Vihang Patil

Date: 12 Jan, 2012 11:57:07

Message: 1 of 4

Hello
I have this particular type or array,example

a = [0 0.0360 NaN NaN NaN 0.0040 0.0530 NaN NaN NaN NaN 0.0080 NaN NaN ]
Now I want the array b such that
b = [0 0.0040 0.0080] and its indices as well such that
index = [1 6 12]
so on and so forth
My main aim is to get only the first numeric value in between the 2 NaN's, if there are 2 or more numeric values in between the NaN's I want to ignore them
How do I achieve this?

Thanks

Vihang

Subject: array question

From: Jaap

Date: 12 Jan, 2012 13:56:08

Message: 2 of 4

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message <jemhqj$hs3$1@newscl01ah.mathworks.com>...
> Hello
> I have this particular type or array,example
>
> a = [0 0.0360 NaN NaN NaN 0.0040 0.0530 NaN NaN NaN NaN 0.0080 NaN NaN ]
> Now I want the array b such that
> b = [0 0.0040 0.0080] and its indices as well such that
> index = [1 6 12]
> so on and so forth
> My main aim is to get only the first numeric value in between the 2 NaN's, if there are 2 or more numeric values in between the NaN's I want to ignore them
> How do I achieve this?
>
> Thanks
>
> Vihang

something like this?
b = a(diff(isnan([NaN,a,NaN]))==-1)

Subject: array question

From: Vihang Patil

Date: 12 Jan, 2012 14:23:08

Message: 3 of 4

"Jaap" wrote in message <jemopo$ab2$1@newscl01ah.mathworks.com>...
> "Vihang Patil" <vihang_patil@yahoo.com> wrote in message <jemhqj$hs3$1@newscl01ah.mathworks.com>...
> > Hello

>
> something like this?
> b = a(diff(isnan([NaN,a,NaN]))==-1)

Hello
Thanks, can you tell me how do I get the indices of the same..

Regards
Vihang

Subject: array question

From: Bruno Luong

Date: 12 Jan, 2012 15:36:07

Message: 4 of 4

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message <jemqcc$fmg$1@newscl01ah.mathworks.com>...
> "Jaap" wrote in message <jemopo$ab2$1@newscl01ah.mathworks.com>...
> > "Vihang Patil" <vihang_patil@yahoo.com> wrote in message <jemhqj$hs3$1@newscl01ah.mathworks.com>...
> > > Hello
>
> >
> > something like this?
> > b = a(diff(isnan([NaN,a,NaN]))==-1)
>
> Hello
> Thanks, can you tell me how do I get the indices of the same..
>

Another way:
ind = strfind([true isnan(a)],[1 0])

Bruno

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