Thread Subject: modify a line in matlab

Subject: modify a line in matlab

From: Clem

Date: 14 May, 2008 20:34:31

Message: 1 of 2

Hello,
I am running a macro created in tecplot with matlab (see below)

I would like to execute this macro for several files. The only difference between each file is the number at the end of the file. I would like to replace this number each time that Matlab detects it.
For instance, tecplot executes the macro on the file named "C:\clem_2100.dat", and I would like matlab to change this name by "C:\clem_2300.dat" when the macr is done.
My first idea was to read my macro by matlab with the command TEXTREAD and next to replace the number by another, but I don't find a 'replace command'.

So if someone has an idea, I would really appreciate.

Thanks

Clem



#!MC 1100
$!VarSet |MFBD| = 'C:\Documents and Settings\cvezie2\My Documents'
$!READDATASET '"STANDARDSYNTAX" "1.0" "LoadOption" "CaseAndData" "FILENAME_CaseFile" "C:\clem_1600.cas" "FILENAME_DataFile" "C:\clem_2100.dat" "GridZones" "CellsAndBoundaries" "IncludeParticleData" "No" "AverageToNodes" "No"'
DATASETREADER = 'Fluent Data Loader'
$!GLOBALTHREED SLICE{NORMAL{X = 1}}
$!GLOBALTHREED SLICE{NORMAL{Z = 0}}
$!CREATESLICEZONEFROMPLANE
SLICESOURCE = VOLUMEZONES
FORCEEXTRACTIONTOSINGLEZONE = YES
$!ADDONCOMMAND
ADDONID = 'CFDAnalyzer3'
COMMAND = 'Calculate Function=\'VELOCITYMAG\' CalculateOnDemand=\'T\''
$!WRITEDATASET "C:\Documents and Settings\cvezie2\Desktop\test1_matlab.dat"
INCLUDETEXT = NO
INCLUDEGEOM = NO
INCLUDECUSTOMLABELS = NO
ASSOCIATELAYOUTWITHDATAFILE = NO
ZONELIST = [10]
VARPOSITIONLIST = [1-4,7,12,17,44-45]
BINARY = NO
USEPOINTFORMAT = YES
PRECISION = 9
$!RemoveVar |MFBD|

Subject: modify a line in matlab

From: Pekka

Date: 15 May, 2008 07:26:01

Message: 2 of 2

Clem <c_vezier@hotmail.com> wrote in message
<10163169.1210797302406.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hello,
> I am running a macro created in tecplot with matlab (see
below)
>
> I would like to execute this macro for several files. The
only difference between each file is the number at the end
of the file. I would like to replace this number each time
that Matlab detects it.
> For instance, tecplot executes the macro on the file
named "C:\clem_2100.dat", and I would like matlab to change
this name by "C:\clem_2300.dat" when the macr is done.
> My first idea was to read my macro by matlab with the
command TEXTREAD and next to replace the number by another,
but I don't find a 'replace command'.
>
> So if someone has an idea, I would really appreciate.
>
> Thanks
>
> Clem
>
>
>
> #!MC 1100
> $!VarSet |MFBD| = 'C:\Documents and Settings\cvezie2\My
Documents'
> $!READDATASET
'"STANDARDSYNTAX" "1.0" "LoadOption" "CaseAndData" "FILENAME_CaseFile" "C:\clem_1600.cas" "FILENAME_DataFile" "C:\clem_2100.dat" "GridZones" "CellsAndBoundaries" "IncludeParticleData" "No" "AverageToNodes" "No"'
 
> DATASETREADER = 'Fluent Data Loader'
> $!GLOBALTHREED SLICE{NORMAL{X = 1}}
> $!GLOBALTHREED SLICE{NORMAL{Z = 0}}
> $!CREATESLICEZONEFROMPLANE
> SLICESOURCE = VOLUMEZONES
> FORCEEXTRACTIONTOSINGLEZONE = YES
> $!ADDONCOMMAND
> ADDONID = 'CFDAnalyzer3'
> COMMAND = 'Calculate Function=\'VELOCITYMAG\'
CalculateOnDemand=\'T\''
> $!WRITEDATASET "C:\Documents and
Settings\cvezie2\Desktop\test1_matlab.dat"
> INCLUDETEXT = NO
> INCLUDEGEOM = NO
> INCLUDECUSTOMLABELS = NO
> ASSOCIATELAYOUTWITHDATAFILE = NO
> ZONELIST = [10]
> VARPOSITIONLIST = [1-4,7,12,17,44-45]
> BINARY = NO
> USEPOINTFORMAT = YES
> PRECISION = 9
> $!RemoveVar |MFBD|

doc strrep
doc regexprep

For less coding in MATLAB you could use replaceinfile from
the file exchange: http://www.mathworks.com/matlabcentral/
fileexchange/loadFile.do?objectId=18909&objectType=FILE


Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com