필터 지우기
필터 지우기

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

조회 수: 2 (최근 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에서 Data Import and Analysis에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by