Filename IDL to Matlab Conversion

3 次查看(过去 30 天)
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

采纳的回答

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