How to fopen in this case?

조회 수: 1 (최근 30일)
dmfwlansejr
dmfwlansejr 2023년 2월 21일
댓글: dmfwlansejr 2023년 2월 21일
Hi Everybody
Case1
fid = fopen('TTL_1.txt', 'w');
fprintf(fid3,'%s \n','ABCD;');
fclose(fid3);
Case2
file_name='TTL_1';
fid = fopen('file_name.txt', 'w');
fprintf(fid3,'%s \n','ABCD;');
fclose(fid3);
Case1 is OK!
However, Case 2 does not create a file.
How to fopen in this case?
Thanks!

채택된 답변

the cyclist
the cyclist 2023년 2월 21일
You need to concatenate two character arrays, one of which you defined ahead ...
file_name='TTL_1';
fid = fopen([file_name,'.txt'], 'w');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by