Can I use fopen with num2str ?

Hi I have this problem, I have a lot of file and for read it I use this command:
if true
% fid=fopen('cassone_freebody_data100001fx.dat','rt'); end
If I like to change that number 100001 How can I do?
I tried to write this command but it doesn't work
if true
% fid=fopen('cassone_freebody_data',num2str(100001),'fx.dat','rt'); end
I like to link 100001 to a variable so to build a for function to increment this number please help me

 채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 17일

0 개 추천

fopen(['cassone_freebody_data',num2str(100001),'fx.dat'],'rt')
Or use sprintf
fopen(sprintf(cassone_freebody_data%06dfx.dat', 100001), 'rt')

추가 답변 (2개)

Jan
Jan 2013년 2월 17일

0 개 추천

Of course such problems occurred in the work of others also. Therefore I can encourage you to ask your favorite search engine before asking the forum:
zaqsedc
zaqsedc 2013년 2월 19일

0 개 추천

sorry I traied but I was so tired anyway thak you so much

카테고리

도움말 센터File Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by