Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Saving array values as .mat file

조회 수: 3 (최근 30일)
adi kul
adi kul 2019년 2월 12일
마감: adi kul 2019년 2월 13일
Hello All,
What I am trying to do is I have bunch of .csv files. Most of them have autogenerated garbage things written before the actual tables are available.
So far I was able to remove this garbage thing and could able to save only tables with following code.
Next thing I want is to save that table from each csv file as .mat which I am not able to do.
This code is generating .mat file but have "x" array in it. Instead I want to have all the data inside x in that mat file.
clear all
close all
d = uigetdir();
filePattern = fullfile(d, '*.csv');
file = dir(filePattern);
x = cell(1, numel(file));
for k = 1 : numel(file)
baseFileName = file(k).name;
fullFileName = fullfile(d, baseFileName);
x{k} = readtable(fullFileName);
fprintf('read file %s\n', fullFileName);
fprintf('read file %s\n', baseFileName);
writetable(x{k},fullFileName);
%MyFile=strcat(baseFileName);
save([baseFileName '.mat'],'x')
end
I hope this is making any sense.
  댓글 수: 11
Walter Roberson
Walter Roberson 2019년 2월 13일
table2struct(YourTable(3:end,:))
adi kul
adi kul 2019년 2월 13일
편집: adi kul 2019년 2월 13일
can I get it to double array instead of cell array ?
Edit:
I will close this question and open a new as the question I asked here is solved. I will open new question for cell array to matrix conversion.

답변 (0개)

이 질문은 마감되었습니다.

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by