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:
effective way to extract cell data according to Time vector?

Subject: effective way to extract cell data according to Time vector?

From: Skirt Zhang

Date: 21 Jul, 2011 13:46:24

Message: 1 of 3

 Dear ALL,

I have two contemporaneous cell arrays"Days" and "Price" , and a vector (17*1) called "Time" defined as below:

days =

    [15x1 double] [9x1 double] [7x1 double]
days{1}=[733043
      733044
      733045
      733046
      733047
      733048
      733049
      733050
      733051
      733052
      733053
      733054
      733055
      733056
      733057]
days{2}=[733044
      733045
      733046
      733047
      733048
      733049
      733050
      733051
      733052]
days{3}=[733052
      733053
      733054
      733056
      733057
      733058
      733059]

price =

    [15x1 double] [14x1 double] [7x1 double]

 price{1} =[0.1100
    0.0339
    0.4411
    0.1298
    0.9716
    0.9402
    0.9331
    0.9838
    0.6930
    0.7025
    0.3713
    0.0641
    0.4435
    0.5430
    0.5402]

 price{2}=[0.7863
    0.6014
    0.9470
    0.6312
    0.8788
    0.1227
    0.8135
    0.9776
    0.2312
    0.9127
    0.6764
    0.7251
    0.6858
    0.7967]
price{3}=[0.8788
    0.6097
    0.9678
    0.6341
    0.7773
    0.8985
    0.2266]
Time=[733043
      733044
      733045
      733046
      733047
      733048
      733049
      733050
      733051
      733052
      733053
      733054
      733055
      733056
      733057
      733058
      733059]

I want to create a new cell called "New_price" with size(17,1) corresponding to the Time vector.

New_price{1} will store the price 0.1100 from price{1} at date 733043.
..
New_price{10} will store the prices at 733052 from price{1}to price{3}, since they all share this common date.
..
New_price{17} will store the price 0.2266 from price{3} at date 733059.

How could I obtain this result in an effective way?

Many thanks

Subject: effective way to extract cell data according to Time vector?

From: Bruno Luong

Date: 21 Jul, 2011 21:17:09

Message: 2 of 3

"Skirt Zhang" <silence_qunzi@hotmail.com> wrote in message <j09ajg$8f3$1@newscl01ah.mathworks.com>...

>
> How could I obtain this result in an effective way?
>

It's odd that price{2} and days{2} do not have the same size, the rest however does. I think you should work out to describe effectively the problem to be solved.

Bruno

Subject: effective way to extract cell data according to Time vector?

From: TideMan

Date: 21 Jul, 2011 21:38:52

Message: 3 of 3

On Jul 22, 9:17 am, "Bruno Luong" <b.lu...@fogale.findmycountry>
wrote:
> "Skirt Zhang" <silence_qu...@hotmail.com> wrote in message <j09ajg$8f...@newscl01ah.mathworks.com>...
>
> > How could I obtain this result in an effective way?
>
> It's odd that price{2} and days{2} do not have the same size, the rest however does. I think you should work out to describe effectively the problem to be solved.
>
> Bruno

Yes, as Bruno says, you need to sort out the dimensions of cell 2.
Then just use an index:
indx=days{1} - Time(1) + 1;
NewPrice(indx,1)=price(1);
etc
etc

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