필터 지우기
필터 지우기

Filename IDL to Matlab Conversion

조회 수: 3 (최근 30일)
Benjamin
Benjamin 2012년 6월 26일
Okay so I'm trying to convert a couple IDL programs into MatLab programs, I'm using the IDL2Matlab program but it seems to have some issues with certain things so i'm trying to clean them up.
My question is:
The IDL was saving a file name as such:
ival_filename = '*ival.' + smode + '.txt';
where smode is a global variable it's taking these 3 parts and using them to name files
How would I do this in matlab?
Thanks
  댓글 수: 1
tlawren
tlawren 2012년 6월 26일
What does the * mean in '*ival.'?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 6월 26일
ival_filename = ['*ival.', smode, '.txt'];

추가 답변 (1개)

tlawren
tlawren 2012년 6월 26일
I'm not completely sure what you are trying to do, but if you are simply wanting to construct a string to use as a filename then that is pretty easy. Consider the following example.
fpre = 'ival'; % prefix
fext = '.txt'; % file extension
smode = pi; % as an example
% combine fpre, smode, and fext to form filename
fname = [fpre, num2str(smode), fext];
The above will yield ival3.1416.txt. Note, smode is numeric in this example. If smode is a character or string, then you can just use:
fname = [fpre, smode, fext];
I hope this answers your question.

카테고리

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