Results 1 to 4 of 4

Math Help - Matlab counting syntax problem

  1. #1
    Newbie
    Joined
    Oct 2009
    Posts
    21

    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 05:41 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2009
    Posts
    21
    Thanks for help and example mate. That function should do the work.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    No worries. Glad I could help you out. Good luck with the rest of your program.

    Regards Elbarto
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab Numerical Integration - Syntax/Style Query
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 9th 2010, 07:35 AM
  2. Help needed in Syntax writing in MATLAB
    Posted in the Math Software Forum
    Replies: 4
    Last Post: March 2nd 2010, 10:49 PM
  3. Mathematica Syntax problem?
    Posted in the Math Software Forum
    Replies: 0
    Last Post: October 11th 2009, 06:37 AM
  4. syntax
    Posted in the LaTeX Help Forum
    Replies: 1
    Last Post: May 9th 2009, 02:30 PM
  5. Matlab: Syntax error in arguments to LM-function???
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 15th 2007, 04:37 AM

Search Tags


/mathhelpforum @mathhelpforum