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

Converting CSV files to mat files

by

 

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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
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;

%%%%%%%%%

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?

Contact us