Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > Mathematics Software Discussion
Reply
 
Thread Tools Display Modes
  #1  
Old October 22nd, 2009, 04:54 AM
Newbie
 
Join Date: Oct 2009
Posts: 21
Country:
Thanks: 4
Thanked 3 Times in 3 Posts
jalko is on a distinguished road
Default Matlab counting syntax problem

Hi there,

I'm new to Matlab language and I need some help to complete one script. It's about computing continuous compounded returns from data as:

Code:
function z=brm(x)
[n,m]=size(x);
c=m-1;
for l=0:c
    for k=l+1:m-1
        z((l+1),k)=log(x(m-l))-log(x(m-k))
    end
end
My problem is that i need to constrain it to compute returns only within selected period of time. I have dada matrix arranged as(Date format=d.m):
Code:
Date, Time, Value
1.1, 1430, 1
1.1, 1431, 2
1.1, 1432, 5
...
1.1, 2259, 3
2.1, 1430, 8
2.1, 1431, 4
...
I do not know how to set condition such will constrain it to prevent compute returns from lag higher than highest possible remaining lag within current day.

Can someone help and show me way?

Thanks for reading,
Tom.

Last edited by CaptainBlack; October 22nd, 2009 at 06:41 AM.
Reply With Quote
Advertisement
 
  #2  
Old October 23rd, 2009, 12:30 AM
Member
 
Join Date: Mar 2007
Posts: 104
Country:
Thanks: 17
Thanked 14 Times in 14 Posts
elbarto is on a distinguished road
Default

Try "datenum". In the example below I assumed your date data was a string and all from the same year (2009).

Code:
mydate = '8.5';%8th of May
A = regexp('8.5','\.','split');%spit string
D = [str2num(A{2}) str2num(A{1}) 2009];%[month  day  year]
sD = datenum(D);%convert to serial date number

%test with date serial 
sD < datenum([5 9 2009])%before 9th of May
sD > datenum([5 7 2009])%after 7th of May
Code:
ans =

     1


ans =

     1

EDU>>
Regards Elbarto
Reply With Quote
The following users thank elbarto for this useful post:
Donate to MHF
  #3  
Old October 23rd, 2009, 02:02 AM
Newbie
 
Join Date: Oct 2009
Posts: 21
Country:
Thanks: 4
Thanked 3 Times in 3 Posts
jalko is on a distinguished road
Default

Thanks for help and example mate. That function should do the work.
Reply With Quote
  #4  
Old October 23rd, 2009, 07:25 AM
Member
 
Join Date: Mar 2007
Posts: 104
Country:
Thanks: 17
Thanked 14 Times in 14 Posts
elbarto is on a distinguished road
Default

No worries. Glad I could help you out. Good luck with the rest of your program.

Regards Elbarto
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 04:15 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.