Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

.csv to .mat

Asked by 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

Andy

Products

No products are associated with this question.

1 Answer

Answer by 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

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 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 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'.

Walter Roberson

Contact us