Got Questions? Get Answers.
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:
find baseline in a signal

Subject: find baseline in a signal

From: muzaffar

Date: 1 Dec, 2008 12:24:02

Message: 1 of 12

Dear All,
I am looking for a matlab program to find baseline in a signal.
i have a signal with 10 different peaks.(for example)
these peaks are separated by some baseline with close to zero but not exactly zero values.
atleast there are 50 data points for these baselines.
thanks for any support
kind regards.

Subject: find baseline in a signal

From: David

Date: 1 Dec, 2008 13:39:03

Message: 2 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> Dear All,
> I am looking for a matlab program to find baseline in a signal.
> i have a signal with 10 different peaks.(for example)
> these peaks are separated by some baseline with close to zero but not exactly zero values.
> atleast there are 50 data points for these baselines.
> thanks for any support
> kind regards.
>

like this:
>> a=[1 5 1 0 2 1 10 1 20 1]

a =

     1 5 1 0 2 1 10 1 20 1

>> b=a(a<=2)

b =

     1 1 0 2 1 1 1

>>

Subject: find baseline in a signal

From: muzaffar

Date: 1 Dec, 2008 15:32:01

Message: 3 of 12

"David" <dave@bigcompany.com> wrote in message <gh0pdm$62o$1@fred.mathworks.com>...
> "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> > Dear All,
> > I am looking for a matlab program to find baseline in a signal.
> > i have a signal with 10 different peaks.(for example)
> > these peaks are separated by some baseline with close to zero but not exactly zero values.
> > atleast there are 50 data points for these baselines.
> > thanks for any support
> > kind regards.
> >
>
> like this:
> >> a=[1 5 1 0 2 1 10 1 20 1]
>
> a =
>
> 1 5 1 0 2 1 10 1 20 1
>
> >> b=a(a<=2)
>
> b =
>
> 1 1 0 2 1 1 1
>
> >>
thanks for you reply,
ok, if i would say
a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
plot(a)
b=(a<=2);
hold on
plot(b,'r')
then i can see the values from b = 1 is baseline. my above example
values for index 1 to 7 then
15 to 19 and lastly from 29 to last
 are supposed to be base line.
i want to get index values of these baselines.
so that in the end i can extract two signal parts. out of original one.

Subject: find baseline in a signal

From: David

Date: 1 Dec, 2008 17:09:02

Message: 4 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh101h$2gn$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gh0pdm$62o$1@fred.mathworks.com>...
> > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> > > Dear All,
> > > I am looking for a matlab program to find baseline in a signal.
> > > i have a signal with 10 different peaks.(for example)
> > > these peaks are separated by some baseline with close to zero but not exactly zero values.
> > > atleast there are 50 data points for these baselines.
> > > thanks for any support
> > > kind regards.
> > >
> >
> > like this:
> > >> a=[1 5 1 0 2 1 10 1 20 1]
> >
> > a =
> >
> > 1 5 1 0 2 1 10 1 20 1
> >
> > >> b=a(a<=2)
> >
> > b =
> >
> > 1 1 0 2 1 1 1
> >
> > >>
> thanks for you reply,
> ok, if i would say
> a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> plot(a)
> b=(a<=2);
> hold on
> plot(b,'r')
> then i can see the values from b = 1 is baseline. my above example
> values for index 1 to 7 then
> 15 to 19 and lastly from 29 to last
> are supposed to be base line.
> i want to get index values of these baselines.
> so that in the end i can extract two signal parts. out of original one.
>
>
>

well, if you do:
b=find(a<=2);
it will give you the list of indices like:
b =

  Columns 1 through 15

     1 2 3 4 5 6 7 8 11 15 16 17 18 19 20

  Columns 16 through 23

    25 26 29 30 31 32 33 34

but maybe you are more interested in a logical mask like just:

>> b= a<=2

b =

  Columns 1 through 15

     1 1 1 1 1 1 1 1 0 0 1 0 0 0 1

  Columns 16 through 30

     1 1 1 1 1 0 0 0 0 1 1 0 0 1 1

  Columns 31 through 34

     1 1 1 1

that would just give you 1's where the condition is satisfied and 0 otherwise?

how do you want to 'extract two parts'?? do you need to keep the indexes in order? or just get the values so you can do statistics on them. when you start talking about plotting the two things after separating it seems like you want to keep them in the same size vectors so you can overplot and get the original back, but then how do you fill the gaps in one or the other??

Subject: find baseline in a signal

From: muzaffar

Date: 1 Dec, 2008 17:22:01

Message: 5 of 12

"David" <dave@bigcompany.com> wrote in message <gh15ne$fc8$1@fred.mathworks.com>...
> "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh101h$2gn$1@fred.mathworks.com>...
> > "David" <dave@bigcompany.com> wrote in message <gh0pdm$62o$1@fred.mathworks.com>...
> > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> > > > Dear All,
> > > > I am looking for a matlab program to find baseline in a signal.
> > > > i have a signal with 10 different peaks.(for example)
> > > > these peaks are separated by some baseline with close to zero but not exactly zero values.
> > > > atleast there are 50 data points for these baselines.
> > > > thanks for any support
> > > > kind regards.
> > > >
> > >
> > > like this:
> > > >> a=[1 5 1 0 2 1 10 1 20 1]
> > >
> > > a =
> > >
> > > 1 5 1 0 2 1 10 1 20 1
> > >
> > > >> b=a(a<=2)
> > >
> > > b =
> > >
> > > 1 1 0 2 1 1 1
> > >
> > > >>
> > thanks for you reply,
> > ok, if i would say
> > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > plot(a)
> > b=(a<=2);
> > hold on
> > plot(b,'r')
> > then i can see the values from b = 1 is baseline. my above example
> > values for index 1 to 7 then
> > 15 to 19 and lastly from 29 to last
> > are supposed to be base line.
> > i want to get index values of these baselines.
> > so that in the end i can extract two signal parts. out of original one.
> >
> >
> >
>
> well, if you do:
> b=find(a<=2);
> it will give you the list of indices like:
> b =
>
> Columns 1 through 15
>
> 1 2 3 4 5 6 7 8 11 15 16 17 18 19 20
>
> Columns 16 through 23
>
> 25 26 29 30 31 32 33 34
>
> but maybe you are more interested in a logical mask like just:
>
> >> b= a<=2
>
> b =
>
> Columns 1 through 15
>
> 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1
>
> Columns 16 through 30
>
> 1 1 1 1 1 0 0 0 0 1 1 0 0 1 1
>
> Columns 31 through 34
>
> 1 1 1 1
>
> that would just give you 1's where the condition is satisfied and 0 otherwise?
>
> how do you want to 'extract two parts'?? do you need to keep the indexes in order? or just get the values so you can do statistics on them. when you start talking about plotting the two things after separating it seems like you want to keep them in the same size vectors so you can overplot and get the original back, but then how do you fill the gaps in one or the other??
Thanks for your reply.
Well, i want to get two signal parts from the original one.
if you plz plot the graph then it can be seen that there are actually two signals and i need to separate to have them in two different variables.
baseline can be choosen in the middle so that half will go to both if we talk about the middle baseline for example.
kind regards.

Subject: find baseline in a signal

From: David

Date: 1 Dec, 2008 18:20:19

Message: 6 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh16fp$spk$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gh15ne$fc8$1@fred.mathworks.com>...
> > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh101h$2gn$1@fred.mathworks.com>...
> > > "David" <dave@bigcompany.com> wrote in message <gh0pdm$62o$1@fred.mathworks.com>...
> > > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> > > > > Dear All,
> > > > > I am looking for a matlab program to find baseline in a signal.
> > > > > i have a signal with 10 different peaks.(for example)
> > > > > these peaks are separated by some baseline with close to zero but not exactly zero values.
> > > > > atleast there are 50 data points for these baselines.
> > > > > thanks for any support
> > > > > kind regards.
> > > > >
> > > >
> > > > like this:
> > > > >> a=[1 5 1 0 2 1 10 1 20 1]
> > > >
> > > > a =
> > > >
> > > > 1 5 1 0 2 1 10 1 20 1
> > > >
> > > > >> b=a(a<=2)
> > > >
> > > > b =
> > > >
> > > > 1 1 0 2 1 1 1
> > > >
> > > > >>
> > > thanks for you reply,
> > > ok, if i would say
> > > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > plot(a)
> > > b=(a<=2);
> > > hold on
> > > plot(b,'r')
> > > then i can see the values from b = 1 is baseline. my above example
> > > values for index 1 to 7 then
> > > 15 to 19 and lastly from 29 to last
> > > are supposed to be base line.
> > > i want to get index values of these baselines.
> > > so that in the end i can extract two signal parts. out of original one.
> > >
> > >
> > >
> >
> > well, if you do:
> > b=find(a<=2);
> > it will give you the list of indices like:
> > b =
> >
> > Columns 1 through 15
> >
> > 1 2 3 4 5 6 7 8 11 15 16 17 18 19 20
> >
> > Columns 16 through 23
> >
> > 25 26 29 30 31 32 33 34
> >
> > but maybe you are more interested in a logical mask like just:
> >
> > >> b= a<=2
> >
> > b =
> >
> > Columns 1 through 15
> >
> > 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1
> >
> > Columns 16 through 30
> >
> > 1 1 1 1 1 0 0 0 0 1 1 0 0 1 1
> >
> > Columns 31 through 34
> >
> > 1 1 1 1
> >
> > that would just give you 1's where the condition is satisfied and 0 otherwise?
> >
> > how do you want to 'extract two parts'?? do you need to keep the indexes in order? or just get the values so you can do statistics on them. when you start talking about plotting the two things after separating it seems like you want to keep them in the same size vectors so you can overplot and get the original back, but then how do you fill the gaps in one or the other??
> Thanks for your reply.
> Well, i want to get two signal parts from the original one.
> if you plz plot the graph then it can be seen that there are actually two signals and i need to separate to have them in two different variables.
> baseline can be choosen in the middle so that half will go to both if we talk about the middle baseline for example.
> kind regards.
>
>

I don't see 2 signals. i see one signal and a classification of the points in the signal as being above or below some threshold value.

Try this exercise:

Given:
a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];

Show the 2 signals you want out of that sequence:
signal1=[???]
signal2=[???]

no formulas, do not show your work, just fill in the ??? values in the order you want to see them in the 2 signals.

Subject: find baseline in a signal

From: muzaffar

Date: 2 Dec, 2008 09:03:01

Message: 7 of 12

"David" <dave@bigcompany.com> wrote in message <gh19t3$81o$1@fred.mathworks.com>...
> "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh16fp$spk$1@fred.mathworks.com>...
> > "David" <dave@bigcompany.com> wrote in message <gh15ne$fc8$1@fred.mathworks.com>...
> > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh101h$2gn$1@fred.mathworks.com>...
> > > > "David" <dave@bigcompany.com> wrote in message <gh0pdm$62o$1@fred.mathworks.com>...
> > > > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh0l12$421$1@fred.mathworks.com>...
> > > > > > Dear All,
> > > > > > I am looking for a matlab program to find baseline in a signal.
> > > > > > i have a signal with 10 different peaks.(for example)
> > > > > > these peaks are separated by some baseline with close to zero but not exactly zero values.
> > > > > > atleast there are 50 data points for these baselines.
> > > > > > thanks for any support
> > > > > > kind regards.
> > > > > >
> > > > >
> > > > > like this:
> > > > > >> a=[1 5 1 0 2 1 10 1 20 1]
> > > > >
> > > > > a =
> > > > >
> > > > > 1 5 1 0 2 1 10 1 20 1
> > > > >
> > > > > >> b=a(a<=2)
> > > > >
> > > > > b =
> > > > >
> > > > > 1 1 0 2 1 1 1
> > > > >
> > > > > >>
> > > > thanks for you reply,
> > > > ok, if i would say
> > > > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > > plot(a)
> > > > b=(a<=2);
> > > > hold on
> > > > plot(b,'r')
> > > > then i can see the values from b = 1 is baseline. my above example
> > > > values for index 1 to 7 then
> > > > 15 to 19 and lastly from 29 to last
> > > > are supposed to be base line.
> > > > i want to get index values of these baselines.
> > > > so that in the end i can extract two signal parts. out of original one.
> > > >
> > > >
> > > >
> > >
> > > well, if you do:
> > > b=find(a<=2);
> > > it will give you the list of indices like:
> > > b =
> > >
> > > Columns 1 through 15
> > >
> > > 1 2 3 4 5 6 7 8 11 15 16 17 18 19 20
> > >
> > > Columns 16 through 23
> > >
> > > 25 26 29 30 31 32 33 34
> > >
> > > but maybe you are more interested in a logical mask like just:
> > >
> > > >> b= a<=2
> > >
> > > b =
> > >
> > > Columns 1 through 15
> > >
> > > 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1
> > >
> > > Columns 16 through 30
> > >
> > > 1 1 1 1 1 0 0 0 0 1 1 0 0 1 1
> > >
> > > Columns 31 through 34
> > >
> > > 1 1 1 1
> > >
> > > that would just give you 1's where the condition is satisfied and 0 otherwise?
> > >
> > > how do you want to 'extract two parts'?? do you need to keep the indexes in order? or just get the values so you can do statistics on them. when you start talking about plotting the two things after separating it seems like you want to keep them in the same size vectors so you can overplot and get the original back, but then how do you fill the gaps in one or the other??
> > Thanks for your reply.
> > Well, i want to get two signal parts from the original one.
> > if you plz plot the graph then it can be seen that there are actually two signals and i need to separate to have them in two different variables.
> > baseline can be choosen in the middle so that half will go to both if we talk about the middle baseline for example.
> > kind regards.
> >
> >
>
> I don't see 2 signals. i see one signal and a classification of the points in the signal as being above or below some threshold value.
>
> Try this exercise:
>
> Given:
> a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
>
> Show the 2 signals you want out of that sequence:
> signal1=[???]
> signal2=[???]
>
> no formulas, do not show your work, just fill in the ??? values in the order you want to see them in the 2 signals.
>
Thanks for your care and reply.
 a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
Please note that i dont mean to slide the sequence in middle.
kind regards.

Subject: find baseline in a signal

From: David

Date: 2 Dec, 2008 12:37:01

Message: 8 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh2tk5$mp7$1@fred.mathworks.com>...
> Thanks for your care and reply.
> a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
> s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> Please note that i dont mean to slide the sequence in middle.
> kind regards.
>

ok, i am lost. that doesn't look like anything i was expecting from your description of trying to separate out the 'baseline' in the signal. it looks like you split the sequence in half, but kept one point common between them. exactly how did you decide which points from 'a' went into 's1' and 's2'??

Subject: find baseline in a signal

From: muzaffar

Date: 2 Dec, 2008 13:28:01

Message: 9 of 12

"David" <dave@bigcompany.com> wrote in message <gh3a5d$9n5$1@fred.mathworks.com>...
> "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh2tk5$mp7$1@fred.mathworks.com>...
> > Thanks for your care and reply.
> > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
> > s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > Please note that i dont mean to slide the sequence in middle.
> > kind regards.
> >
>
> ok, i am lost. that doesn't look like anything i was expecting from your description of trying to separate out the 'baseline' in the signal. it looks like you split the sequence in half, but kept one point common between them. exactly how did you decide which points from 'a' went into 's1' and 's2'??
Well,
if i consider the values 1 2 1 for example baseline then i want to slice in the middle
again if there are data points 1 2 1 2 1 2 1 2
now for a different original array "a"
there are eight points if example first data 1 has in the original array "a" index 64.
and the last 2 of the above points would be index 71
then round of (64+71)/2 would be the point u mentioned.
thanks

Subject: find baseline in a signal

From: David

Date: 2 Dec, 2008 14:00:18

Message: 10 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh3d51$m3c$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gh3a5d$9n5$1@fred.mathworks.com>...
> > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh2tk5$mp7$1@fred.mathworks.com>...
> > > Thanks for your care and reply.
> > > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
> > > s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > Please note that i dont mean to slide the sequence in middle.
> > > kind regards.
> > >
> >
> > ok, i am lost. that doesn't look like anything i was expecting from your description of trying to separate out the 'baseline' in the signal. it looks like you split the sequence in half, but kept one point common between them. exactly how did you decide which points from 'a' went into 's1' and 's2'??
> Well,
> if i consider the values 1 2 1 for example baseline then i want to slice in the middle
> again if there are data points 1 2 1 2 1 2 1 2
> now for a different original array "a"
> there are eight points if example first data 1 has in the original array "a" index 64.
> and the last 2 of the above points would be index 71
> then round of (64+71)/2 would be the point u mentioned.
> thanks
>
>

i am still lost. there are only 34 values in 'a'. where does 64 and 71 come into it?

Subject: find baseline in a signal

From: muzaffar

Date: 2 Dec, 2008 14:41:01

Message: 11 of 12

"David" <dave@bigcompany.com> wrote in message <gh3f1i$leq$1@fred.mathworks.com>...
> "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh3d51$m3c$1@fred.mathworks.com>...
> > "David" <dave@bigcompany.com> wrote in message <gh3a5d$9n5$1@fred.mathworks.com>...
> > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh2tk5$mp7$1@fred.mathworks.com>...
> > > > Thanks for your care and reply.
> > > > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > > s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
> > > > s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > > Please note that i dont mean to slide the sequence in middle.
> > > > kind regards.
> > > >
> > >
> > > ok, i am lost. that doesn't look like anything i was expecting from your description of trying to separate out the 'baseline' in the signal. it looks like you split the sequence in half, but kept one point common between them. exactly how did you decide which points from 'a' went into 's1' and 's2'??
> > Well,
> > if i consider the values 1 2 1 for example baseline then i want to slice in the middle
> > again if there are data points 1 2 1 2 1 2 1 2
> > now for a different original array "a"
> > there are eight points if example first data 1 has in the original array "a" index 64.
> > and the last 2 of the above points would be index 71
> > then round of (64+71)/2 would be the point u mentioned.
> > thanks
> >
> >
>
> i am still lost. there are only 34 values in 'a'. where does 64 and 71 come into it?
sorry, i actually presented a new situation.
ok, well now i am giving you same situation.
in
a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
then if somehow i know that
a(15:19) =
1 2 1 2 1
is the base line which separates the two signal parts
then index=(15+19)/2
               =17 is something you mensioned common
so
s1 would be a(1:17)
s2 = a(17:end)
i need to general program.
Now one information about the two 1's at a(11) and a(25)
as these 1's are only once and these are different than baseline "1 2 1 2 etc"

Subject: find baseline in a signal

From: David

Date: 2 Dec, 2008 15:34:01

Message: 12 of 12

"muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh3hdt$10d$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gh3f1i$leq$1@fred.mathworks.com>...
> > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh3d51$m3c$1@fred.mathworks.com>...
> > > "David" <dave@bigcompany.com> wrote in message <gh3a5d$9n5$1@fred.mathworks.com>...
> > > > "muzaffar" <muzaffarbashir@yahoo.com> wrote in message <gh2tk5$mp7$1@fred.mathworks.com>...
> > > > > Thanks for your care and reply.
> > > > > a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > > > s1=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1]
> > > > > s2=[1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> > > > > Please note that i dont mean to slide the sequence in middle.
> > > > > kind regards.
> > > > >
> > > >
> > > > ok, i am lost. that doesn't look like anything i was expecting from your description of trying to separate out the 'baseline' in the signal. it looks like you split the sequence in half, but kept one point common between them. exactly how did you decide which points from 'a' went into 's1' and 's2'??
> > > Well,
> > > if i consider the values 1 2 1 for example baseline then i want to slice in the middle
> > > again if there are data points 1 2 1 2 1 2 1 2
> > > now for a different original array "a"
> > > there are eight points if example first data 1 has in the original array "a" index 64.
> > > and the last 2 of the above points would be index 71
> > > then round of (64+71)/2 would be the point u mentioned.
> > > thanks
> > >
> > >
> >
> > i am still lost. there are only 34 values in 'a'. where does 64 and 71 come into it?
> sorry, i actually presented a new situation.
> ok, well now i am giving you same situation.
> in
> a=[1 2 1 2 1 2 1 2 5 8 1 7 9 4 1 2 1 2 1 2 5 4 6 9 1 2 5 4 1 2 1 2 1 2 ];
> then if somehow i know that
> a(15:19) =
> 1 2 1 2 1
> is the base line which separates the two signal parts
> then index=(15+19)/2
> =17 is something you mensioned common
> so
> s1 would be a(1:17)
> s2 = a(17:end)
> i need to general program.
> Now one information about the two 1's at a(11) and a(25)
> as these 1's are only once and these are different than baseline "1 2 1 2 etc"
>

sounds like you have some requirements gathering and design work yet to do.

First i think you have to define the 'somehow' more specifically in this:
> then if somehow i know that
> a(15:19) =
> 1 2 1 2 1
> is the base line which separates the two signal parts
is the 'baseline' signal ALWAYS and EXACTLY 12121, or can it be 11221211? is it just a threshold value? does it have a minimum length to define a gap between events? is there a maximum length for a baseline gap between events? do you want to save all the baseline time between events? do you want to always split it evenly between events? How do you handle the start and end of the sequence if it is the baseline signal or if its not the baseline signal?

and for a general solution you will probably also have to consider things like: what is the minimum duration of an event? what is the maximum duration? are they periodic or random? and of course, how much data is there and how do you want it presented for later analysis.

after you answer all the questions, and probably find some more, then i think you will have to design a custom solution to locate the splitting points. after that it is just a simple indexing job to break the signal at your defined points and put them somewhere for analysis.

Tags for this Thread

No tags are associated with 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