How to write to CSV file

조회 수: 13 (최근 30일)
Mekala balaji
Mekala balaji 2018년 3월 14일
답변: Walter Roberson 2018년 3월 14일
I have below cell array matrix, and I want to write to csv file in specified folder, with specified name
OuputFilePath: D:\outputData
OuputFileName: OutSuggestion
ParameterName ParameterValue
Gas_Flow.Sugg 0.23
Temperature.Upper 12.3
VSA.Flow.Pressure 0.72

답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 14일
OutputFilePath = 'D:\outputData';
OutputFileName = 'OutSuggestion.csv';
filename = fullfile(OutputFilePath, OutputFileName);
[fid, msg] = fopen(filename, 'wt');
if fid < 0
error('Could not open file "%s" because "%s"', fid, msg);
fprintf(fid, '%s,%s\n', OutputData{1,1}, OutputData{1,2});
temp = OutputData(2:end, :).'; %transpose is important
fprintf(fid, '%s,%f\n', temp{:});


Help CenterFile Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by