Fabian Heinzl
Fabian Heinzl

Reputation: 1

Octave: How to put in a Variable into a Filename for Fopen

I have a Variable which is part of the Name of my Textfile:

Test123_Variable.txt

Now I want to use the Function fopen to open the textfile, but since my Filename is dependent on the name of my variable I don't know how to make the right syntax:

This is obviously not working: filename = ("Test123_Variable.txt");

How can I fix this?

Upvotes: 0

Views: 556

Answers (1)

S. Gougeon
S. Gougeon

Reputation: 911

If i understand right your purpose,

filename = ["Test123_" Variable ".txt"];

should do what you expect. Example:

>> Variable = "sample_1";
>> filename = ["Test123_" Variable ".txt"]
filename = Test123_sample_1.txt

Upvotes: 1

Related Questions