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

4 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2019-11-2
It would be easier to use csvwrite (or writematrix) than creating you own version.
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by