필터 지우기
필터 지우기

use variable name inside dlmwrite with respect to loop variable

조회 수: 2 (최근 30일)
AA
AA 2021년 5월 19일
댓글: AA 2021년 5월 19일
I have 10 files and I want to get output filename loop number .
I use this command to get output for a single file but how can I insert loop name inside file name:
dlmwrite('lag_data.txt',a1,'delimiter',' ')
I want this kind of output
for i=1:4
(commands)
dlmwrite('lag_data.txt',a1,'delimiter',' ')
end
output should be like this
lag_data_1.txt
lag_data_2.txt
lag_data_3.txt
lag_data_4.txt

채택된 답변

Stephen23
Stephen23 2021년 5월 19일
편집: Stephen23 2021년 5월 19일
for k = 1:4
M = ... your matrix
F = sprintf('lag_data_%d.txt',k);
dlmwrite(F, M, 'delimiter',' ')
end

추가 답변 (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