0

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?

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Gee, I never realized that Matlab did that too. And yet, there it is, right in the documentation. I much prefer your use of the unlink command over shelling out for an OS specific deletion command. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.