Be the first to rate this file! 16 Downloads (last 30 days) File Size: 487 Bytes File ID: #22291

Converting CSV files to mat files

by Siamak Faridani

 

01 Dec 2008

This simple script converts all the ASCII *.dat files in the current directory into mat files.

| Watch this File

File Information
Description

This simple script converts all the ASCII *.dat files in the current directory into mat files.

The code is not optimized but may help you in your project. I did not spend so much time refining it therefore if you have done so please post it here

Thank you

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
04 Feb 2010 fran anwar

sir...
how to convert the mat file in matlab to other file format that can be used in catia either ascii (.asc) or other file?

05 Jan 2012 Maria

hi

i've modified your file a little bit. Now all files, that are in the current directory, are not saved in separate .mat files, but in one common.

%%%%%%%%
clc;
close all;
clear all;

matfiles = dir('*.csv');

for ind = 1:length(matfiles)
     M = csvreadmy(matfiles(ind).name);
     varname = genvarname(strrep(matfiles(ind).name,'.csv',''));
    eval([varname ' = M']);
end

clear M ind matfiles varname
save test.mat;

%%%%%%%%%

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
text Siamak Faridani 02 Dec 2008 14:37:21
ascii Siamak Faridani 02 Dec 2008 14:37:21
dat Siamak Faridani 02 Dec 2008 14:37:21
batch process Siamak Faridani 02 Dec 2008 14:37:21
matrix Siamak Faridani 02 Dec 2008 14:37:21
mat Siamak Faridani 02 Dec 2008 14:37:21
dat Winston Wei Dou 26 Jul 2011 15:58:20

Contact us at files@mathworks.com