I'm trying to write my column vector F into an ascii file. The code runs, but it does not write into the ascii file. Please help, the code is shown below.

조회 수: 1 (최근 30일)
start_date = datenum('06-Jun-2014 16:20');
end_date = datenum('09-Jun-2014 12:30');
interval = 10/24/60;
date = datestr(start_date:interval:end_date);
F=datenum(date);
format long g
F
for H=(1:numel(F))';
F = F(H);
dlmwrite('Neph2014average.txt',F,'delimiter','')
end

채택된 답변

Star Strider
Star Strider 2015년 3월 28일
Lose the loop! You only need:
dlmwrite('Neph2014average.txt',F,'delimiter',',')
and it works.
  댓글 수: 2
Dre Og
Dre Og 2015년 3월 28일
Thanks so much Star Strider! I'm good now. I just discovered the problem! The code was good, but I had 2 copies of the output file in 2 different directories. All this while, I have been checking the one in the wrong directory!
Star Strider
Star Strider 2015년 3월 28일
My pleasure!
Uncertainty about paths can be a problem. As Jan Simon pointed out in another recent post, it is always a good idea to specify the full path when writing a file. When I wrote the file with my code and then used dlmread, it imported perfectly. To make sure I found it and checked it independently with ‘notepad’, I used:
specfile = which('Neph2014average.txt')
It gave me the full path and filename.
Never underestimate the unitlity of the which, who, and whos functions! They can make MATLAB programming and debugging significantly easier.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by