Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: truncation problem
Replies: 5   Last Post: Jan 12, 2014 1:48 AM

 Messages: [ Previous | Next ]
 Nasser Abbasi Posts: 6,630 Registered: 2/7/05
Re: truncation problem
Posted: Jan 10, 2014 2:40 AM

On 1/9/2014 11:55 PM, Mohammad Sayeed wrote:
> Dear Nasser
> Thank you for your kind reply. but my problem is more general one.
>say that I have hourly price information in a matrix. in the first column
>I have the hours from 1 to 24 repeatedly for 10 days. in the second column
>I have the prices of each hour for a given stock. I need to get rid of
>first 10 hours and last 4 hours from the matrix and have the 11th to 20th
>hours' data for each ten days. Can I do it by using MATLAB? Your contribution will help me a lot.
>
> Kind regards
>
> Sayeed
>

There are many ways to do this, here is one way, I am sure there
are better ways but I am lazy now

--------------------------
nDays = 5;
nhrs = 24;
data = rand(nDays*nhrs,2);
size(data)

120 2

r = arrayfun(@(i) data(nhrs*(i-1)+11:nhrs*(i-1)+20,:),1:nDays,'UniformOutput',false);
filteredData = cell2mat(r');
size(filteredData)

50 2
-------------------------

--Nasser

Date Subject Author