MATLAB Answers

How can I specify that dlmwrite write to a textfile with the name of an input?

14 views (last 30 days)
For example, I want to write a text file to a directory using dlmwrite, and I want to name the text file as the inputted name. I have:
dlmwrite('/home/mydirectory/auxiliaryData',output, 'delimiter','\t','precision',10 );
and a couple of lines of code ago, I had:
auxiliaryData = input('Input Auxiliary Channel: ');
I don't want the name of the text file to be the name of the variable (auxiliaryData).


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Nov 2015
Edited: Walter Roberson on 7 Nov 2015
projectdir = '/home/mydirectory';
dlmwrite( fullfile(projectdir, auxiliaryData),output, 'delimiter','\t','precision',10 );
You might prefer using
auxiliaryData = input('Input Auxiliary Channel: ', 's');
... I'm not really sure what data type you intend, or what file extension you intend.


Show 1 older comment
Walter Roberson
Walter Roberson on 8 Nov 2015
What would be a typical response to
auxiliaryData = input('Input Auxiliary Channel: ')
? For example would it be a scalar that might be (for example) 2? And if so should that cause the file
to be the output file?
Real Name
Real Name on 8 Nov 2015
The input will be a text file filled with matrices of doubles that is within a lot of nested directories.
So one typical input would be:
Real Name
Real Name on 8 Nov 2015
Also, I'm getting another error message when I run this matlab program. It says "Could not open file"
I believe this is because the directory and text file which I'm accessing the data from are read-only. So I think you're code is outputting back into that directory.
I'm not too sure what the problem is.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!