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

조회 수: 2 (최근 30일)
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).

채택된 답변

Walter Roberson
Walter Roberson 2015년 11월 7일
편집: Walter Roberson 2015년 11월 7일
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.
  댓글 수: 4
Real Name
Real Name 2015년 11월 8일
편집: Walter Roberson 2015년 11월 9일
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:
/home/pulsar/public_html/fscan/L1_DUAL_ARM/L1_DUAL_ARM_DCREADOUT_HANN/L1_DUAL_ARM_DCREADOUT_HANN/fscans_2015_10_01_06_00_02_CDT_Thu/L1_CAL-DELTAL_EXTERNAL_DQ/spec_0.00_100.00_L1_1127646019_1127732419.txt
Real Name
Real Name 2015년 11월 8일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by