user36800
user36800

Reputation: 2259

Octave: Specify diary file using string variable?

I have the following statements to set the diary & diary file:

fnDiary = [ mfilename '.out.txt' ]
system(['rm -f ' fnDiary])
diary off; diary fnDiary

This doesn't work, since Octave thinks I want the diary file name to be "fnDiary". Is there a way to specify the diary file using a string variable?

Upvotes: 0

Views: 282

Answers (1)

Andy
Andy

Reputation: 8091

This is a common error. Octave (and Matlab) treats arguments for a function outside () as string. Use this:

fnDiary = [ mfilename '.out.txt' ]
unlink (fnDiary)
diary off;
diary (fnDiary)

Upvotes: 2

Related Questions