Easier way to rename files?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi all,
I run a code where in the end I rename a bunch of output files based on the date that the data was procured. So if my code finds xData, yData, zData and tData and I want to rename it as the following
xData060912=xData;
yData060912=yData;
zData060912=zData;
tData060912=tData;
clear xData yData zData tData
Is there an easier way to do this? rather than renaming the arrays manually everytime. Can I just input 060912 in one line and use a function that does it automatically?
Thanks, NS
댓글 수: 0
채택된 답변
per isakson
2012년 6월 9일
Something like this is often recommended
str_name = sprintf( 'xData%06u', num )';
Data.(str_name) = xData;
etc.
댓글 수: 3
Walter Roberson
2012년 6월 9일
NS: That approach is not recommended as it usually leads to problems. The approaches in the FAQ that Per referenced are more appropriate.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!