필터 지우기
필터 지우기

Writing a file with columns

조회 수: 2 (최근 30일)
X
X 2011년 7월 11일
Hello, I have a matrix 1000x3, and I want to write that data into a .csv file. The problem I have is that when I open the new file, I have the matrix that I wanted in one column. I want to have 3 columns when I open the excel file (Say A, B, C). Does anyone knows if it is possible to write my data in three separate columns? Thank you
fid = fopen('16.csv','w'); %Opens the file
fprintf(fid, '%5.2f\v %5.2f\v %d\v \n', T_DB, T_DP, RH);
fclose(fid); %Closes the file

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 7월 11일
EDIT
T_DB = rand(1,10);
T_DP = rand(1,10);
RH = 1:10;
fid = fopen('16.csv','w'); %Opens the file
fprintf(fid, '%5.2f,%5.2f,%d\r\n', [T_DB; T_DP; RH]);
fclose(fid);
where T_DB and the others should be row vetors.
  댓글 수: 2
X
X 2011년 7월 11일
Thank you Oleg for your reply, but it did not work. It gives the same answer as before. Thank you again.
Oleg Komarov
Oleg Komarov 2011년 7월 11일
See edit.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by