Effacer les filtres
Effacer les filtres

Filename IDL to Matlab Conversion

3 vues (au cours des 30 derniers jours)
Benjamin
Benjamin le 26 Juin 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 commentaire
tlawren
tlawren le 26 Juin 2012
What does the * mean in '*ival.'?

Connectez-vous pour commenter.

Réponse acceptée

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

Plus de réponses (1)

tlawren
tlawren le 26 Juin 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