Thread Subject: Get Data at regular intervals

Subject: Get Data at regular intervals

From: Vihang Patil

Date: 16 Dec, 2011 15:15:09

Message: 1 of 7

Hello;
I want to get data from a matrix at a regular step size that I specify. For example.
I have a following matrix

C = [0; 0.16; 0.22; 0.34; 0.44; 0.49; 0.52; 0.61; 0.69; 0.76; 0.84; 0.91; 1.05; 1.11; 1.24];

C =

         0
    0.1600
    0.2200
    0.3400
    0.4400
    0.4900
    0.5200
    0.6100
    0.6900
    0.7600
    0.8400
    0.9100
    1.0500
    1.1100
    1.2400

Now, if I specify the step size as 0.5 then I want to get data in C like the following

C =

         0
    0.4900
    1.0500
so on and so forth in 0.5 steps

What I am trying to achieve is that, I have a very big m x 4 matrix. I want to store some of this data in excel file, but I dont want to dump all the data in the matrix in the excel and also it wont be possible too, due to the limitation in columns in excel. So instead if I specify the step size , then I want to get the data that is closest to the specified step size and only that data I want to dump in excel.

Vihang
How can I achieve this?

Subject: Get Data at regular intervals

From: Vihang Patil

Date: 12 Jan, 2012 14:13:07

Message: 2 of 7

any help?

Vihang

Subject: Get Data at regular intervals

From: TideMan

Date: 12 Jan, 2012 19:05:45

Message: 3 of 7

On Dec 17 2011, 4:15 am, "Vihang Patil" <vihang_pa...@yahoo.com>
wrote:
> Hello;
> I want to get data from a matrix at a regular step size that I specify. For example.
> I have a following matrix
>
> C = [0; 0.16; 0.22; 0.34; 0.44; 0.49; 0.52; 0.61; 0.69; 0.76; 0.84; 0.91; 1.05; 1.11; 1.24];
>
> C =
>
>          0
>     0.1600
>     0.2200
>     0.3400
>     0.4400
>     0.4900
>     0.5200
>     0.6100
>     0.6900
>     0.7600
>     0.8400
>     0.9100
>     1.0500
>     1.1100
>     1.2400
>
> Now, if I specify the step size as 0.5 then I want to get data in C like the following
>
> C =
>
>          0
>     0.4900
>     1.0500
> so on and so forth in 0.5 steps
>
> What I am trying to achieve is that, I have a very big m x 4 matrix. I want to store some of this data in excel file, but I dont want to dump all the data in the matrix in the excel and also it wont be possible too, due to the limitation in columns in excel. So instead if I specify the step size , then I want to get the data that is closest to the specified step size and only that data I want to dump in excel.
>
> Vihang
> How can I achieve this?

Here's one way:
t=[1:length(C)]'; % Address vector
Ci=[0:0.5:C(end)]'; % Output vector
indx=round(interp1(C,t,Ci));

Now, C(indx) are the values, but more importantly indx contains the
row numbers for your matrix.

Subject: Get Data at regular intervals

From: Bruno Luong

Date: 12 Jan, 2012 20:07:07

Message: 4 of 7

interp1(C,C,0:0.5:C(end),'neareast')

% Bruno

Subject: Get Data at regular intervals

From: TideMan

Date: 13 Jan, 2012 00:28:02

Message: 5 of 7

On Jan 13, 9:07 am, "Bruno Luong" <b.lu...@fogale.findmycountry>
wrote:
> interp1(C,C,0:0.5:C(end),'neareast')
>
> % Bruno

Hey Bruno

Is "neareast" like the far east?
Or does it mean get the easternmost number?

Subject: Get Data at regular intervals

From: Bruno Luong

Date: 13 Jan, 2012 07:13:07

Message: 6 of 7

TideMan <mulgor@gmail.com> wrote in message <027a7a43-5001-4280-8ceb-f523fdf243a9@h3g2000yqe.googlegroups.com>...

>
> Is "neareast" like the far east?
> Or does it mean get the easternmost number?

LOL, good catch. ;-)

It is of course a typo of 'nearest'.

Bruno

Subject: Get Data at regular intervals

From: Vihang Patil

Date: 13 Jan, 2012 08:25:09

Message: 7 of 7

Thanks Bruno, TideMan
The code worked like magic. You guys are simply awesome!!! .

Regards
Vihang

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jeoli3$rfe$1@newscl01ah.mathworks.com>...
> TideMan <mulgor@gmail.com> wrote in message <027a7a43-5001-4280-8ceb-f523fdf243a9@h3g2000yqe.googlegroups.com>...
>
> >
> > Is "neareast" like the far east?
> > Or does it mean get the easternmost number?
>
> LOL, good catch. ;-)
>
> It is of course a typo of 'nearest'.
>
> 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