Filter löschen
Filter löschen

Filename IDL to Matlab Conversion

3 Ansichten (letzte 30 Tage)
Benjamin
Benjamin am 26 Jun. 2012
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 Kommentar
tlawren
tlawren am 26 Jun. 2012
What does the * mean in '*ival.'?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Jun. 2012
ival_filename = ['*ival.', smode, '.txt'];

Weitere Antworten (1)

tlawren
tlawren am 26 Jun. 2012
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.

Community Treasure Hunt

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

Start Hunting!

Translated by