Error combining two text files

조회 수: 1 (최근 30일)
David (degtusmc)
David (degtusmc) 2013년 7월 18일
Hello everyone,
I followed the solution provided by Fangjun in the following Matlab Answer:
My problem is that 1 of the names of the text files is a variable (since it is taken from user input). I tried the following, but it cannot find the file.
>> header = 'A1.txt';
>> system('copy header+ATEST.txt') %assuming ATEST.txt exist
This is what Matlab displays:
The system cannot find the file specified.
ans = 1
I also tried the following but it gave me an error:
>> system('copy %s+ATEST.txt',header)
Error using system
Unrecognized option: A1.txt
Is there a way to work around this?
Thank you in advance for any help provided.

채택된 답변

David (degtusmc)
David (degtusmc) 2013년 7월 18일
I found a solution (below). If there is any other suggestions, I would be happy to hear them. Thanks.
>> header = 'A1.txt';
>> cmd1 = ['copy ',header];
>> cmd = strcat(cmd1,'+ATEST.txt');
>> system(cmd)
A1.txt
ATEST.txt
1 file(s) copied.
ans = 0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by