Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to use "diary"?

Subject: how to use "diary"?

From: Yi

Date: 25 Jan, 2009 01:04:02

Message: 1 of 2

Hey guys:

I have one question now. I have a long long program and a lot of loops inside the program. It may take the whole night to run the program. When the program stop, I want to see the whole process of the program. However, I printed the whole thing and suddenly found that it only gave me the lastest 150 pages. It's not enough for me. How can I see the whole thing, maybe it's thousands of pages.

Someone suggested I to use the command "diary" and I searched diary in Matlab help, but I still feel difficult to understand how to use it. Should I write this command in Matlab program before running, or after finishing running program.

Could sb tell me how to use the command "diary"?

Thanks & Best Regards

Yi

Subject: how to use "diary"?

From: Steven Lord

Date: 26 Jan, 2009 15:01:47

Message: 2 of 2


"Yi" <hvachy@163.com> wrote in message
news:glgdq2$ljm$1@fred.mathworks.com...
> Hey guys:
>
> I have one question now. I have a long long program and a lot of loops
> inside the program. It may take the whole night to run the program. When
> the program stop, I want to see the whole process of the program. However,
> I printed the whole thing and suddenly found that it only gave me the
> lastest 150 pages. It's not enough for me. How can I see the whole thing,
> maybe it's thousands of pages.
>
> Someone suggested I to use the command "diary" and I searched diary in
> Matlab help, but I still feel difficult to understand how to use it.
> Should I write this command in Matlab program before running, or after
> finishing running program.
>
> Could sb tell me how to use the command "diary"?

Call "diary <diary file name>" before running your code, then call "diary
off" afterwards. Then the file <diary file name> will contain the command
window output from your code.


% Start the diary
diary myFirstDiaryFile.txt

% Run some code
n = 20;
r = randperm(n);
for k = 1:n
    fprintf('Number %d is %d.\n', k, r(k));
end

% End the diary
diary off

% Examine the contents of the diary file
edit myFirstDiaryFile.txt


Make sure you're in a directory in which you have write permissions, or
include the path to such a directory in your DIARY call. Also note that if
your diary file's name and/or path includes a space, you'll need to use the
command form of diary:

diary('My Diary File.txt')

Alternately, instead of using DIARY, you could start MATLAB with
the -logfile switch.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-4994.html#bq24t0c

--
Steve Lord
slord@mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us