Mrityunjay Singh
Mrityunjay Singh

Reputation: 497

How to save the command history in a text file in MATLAB

I want to save the value of a variable from MATLAB command history in a text. I am trying the command:

Save([d:/work/abc.txt], 'z1', '-ASCII');

An error appears

Error: input charecter is not valid in MATLAB environment or expression.

Upvotes: 1

Views: 326

Answers (2)

Dk SAP
Dk SAP

Reputation: 36

What you are missing are the quotes within the brackets for denoting string.

['string']

Upvotes: 2

il_raffa
il_raffa

Reputation: 5190

You should use save (with lower case for "s").

Also the filename should be defined as a string: enclose it withi two '; also you do not need the [] unless, for example, you want to build a string using a variable and / or any function to create part of the filename (e. g.

['d:/work/abc_' num2str(k) '.txt']

assuming k value is 3) to get d:/work/abc_3.txt

Try change your code to:

save(['d:/work/abc.txt'], 'z1', '-ASCII');

Hope this helps.

Qapla

Upvotes: 2

Related Questions