Prev: Numerical Integration
Next: csmatio library for matlab
From: Jarodd Holmes on 28 Jul 2010 18:10 Hello Matlab users! I recently decided to switched to Matlab from Stata (recommendation, flexibility, etc) and I am so as to say a beginner. Your help on the following matter will be gladly appreciated :) I have a structure array with financial data for 50 companies (in 50 cells) called data. Each array with financial data for each company has the following structure: index(this is a number) id(also a number) stock_price date Nr_of_stocks for company 1 it looks like this: [1 3222 32.22 731188 323822; 1 3222 32.24 731189 323822] an so on (daily returns). I want to create a structure array newdata, that contains only the monthly stock prices (for the beginning of the month and the end of the month instead of the daily values) for all companies (all elements of the structure). I read in the help that the function tomonthly should be suitable for my needs. I tried the following command: datanew=cellfun(tomonthly(data)) but I got a nasty error message. I know that my question might need more time to answer, as I am a complete beginner, but I really did try and I will gladly appreciate any help. Thank you all and have a good day!
From: TideMan on 28 Jul 2010 21:36 On Jul 29, 10:10 am, "Jarodd Holmes" <lapaipis...(a)googlemail.com> wrote: > Hello Matlab users! > I recently decided to switched to Matlab from Stata (recommendation, flexibility, etc) and I am so as to say a beginner. Your help on the following matter will be gladly appreciated :) > > I have a structure array with financial data for 50 companies (in 50 cells) called data. > Each array with financial data for each company has the following structure: > index(this is a number) id(also a number) stock_price date Nr_of_stocks > for company 1 it looks like this: > [1 3222 32.22 731188 323822; > 1 3222 32.24 731189 323822] an so on (daily returns). > > I want to create a structure array newdata, that contains only the monthly stock prices (for the beginning of the month and the end of the month instead of the daily values) for all companies (all elements of the structure).. > > I read in the help that the function tomonthly should be suitable for my needs. > I tried the following command: datanew=cellfun(tomonthly(data)) but I got a nasty error message. > > I know that my question might need more time to answer, as I am a complete beginner, but I really did try and I will gladly appreciate any help. > > Thank you all and have a good day! I guess tomonthly is in the financial toolbox, which I don't have. Nevertheless, I can see that you have got the syntax of cellfun wrong. It should be cellfun(@tomonthly,data) Now I cannot guarantee that this will work (because I know nothing about tomonthly), but it has a higher probability of working than your version. You need to check that tomonthly is expecting an array of 4 columns with the time in column 3, otherwise it won't work. All is not lost if this is the case, you'll just have to code up your own tomonthly.
|
Pages: 1 Prev: Numerical Integration Next: csmatio library for matlab |