MATLAB Answers

.csv to .mat

116 views (last 30 days)
Andy
Andy on 24 Mar 2011
How do I convert .csv files into .mat files. Specifically to interchange new files into the scrips from Algorithmic Trading with MATLAB - 2010 (the webinar). I want to use other files instead of "Bund1min.mat"
Files and webinar:
(Algorithmic Trading with MATLAB - 2010 by Stuart Kozola 22 Nov 2010 (Updated 06 Dec 2010) Code covered by the BSD License Files from the November 18, 2010 webinar.)

  0 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 24 Mar 2011
csvread() can be used to load data from csv files. You can then save() the data to a .mat file.

  4 Comments

Show 1 older comment
Andy
Andy on 25 Mar 2011
I am working with the function:
%%file name is in .mat format
d= load('filename');
%% these next couple lines don't seem to work with my newly created file
data=d.data;
lenData = length(data);
Andy
Andy on 25 Mar 2011
Maybe it will help if I say step by step what I am trying to do. I download a intra day stock price history csv file from www.stockrageous.com I can either load it into excel to format(I think I have to do this because their is text and a time col. formatted w/ xx:xx) or can try to load the file directly to matlab. When I try to load it into matlab there are errors. I got the excel file to load in and then save as a .mat file when I format the excel file by not having a time col and removing the text headers.
What I want to do: stockrageous.com .csv file to .mat file so it can load through with the for mentioned code.
If anyone needs clarification let me know. Thanks for your help in advance
Walter Roberson
Walter Roberson on 25 Mar 2011
After you have done the load(), ask to output fieldnames(d) as perhaps the data is not stored in a field named 'data'.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!