is it possible to save csv files in loop with fopen..getting error Error using fopen Invalid permission.

3 Ansichten (letzte 30 Tage)
for k=1:38
Column_1_t=(1:1000)*0.00008
Column_2_output = cellstr(num2str(Y{k}.OutputData));
mag = Y{k}.OutputData;
% change name here to write
% change name here to write
savedfile = folder_name;
fid_out(k) = fopen(num2str(k),'savedfile_.csv','w'); %open file and create fid %here i am getting error
%save tab-separated column headers
%define column format and names and save to file
fprintf(fid_out(k),'%s%s%s\n','time',',','Cal');
fprintf(fid_out(k),'%s%s%s\n','(ms)',',','(V)');
fprintf(fid_out(k),'\n');
%save tab-separated columns of data
for i = 1:size(data,1) %loop trough each line of each data variable and save to file line by line
%define column format and date to be saved.
%use () for numeric data, and {} for strings
fprintf(fid_out(k),'%0.8f%s%0.8f\n',data(i,1),',',data(i,2));
end
fclose(fid_out(k))
end

Akzeptierte Antwort

Star Strider
Star Strider am 2 Nov. 2019
It would be easier to use csvwrite (or writematrix) than creating you own version.
  4 Kommentare

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by