I trying to run another program through MatLab. I have an example of
how to do this, but whenever I tried running the line of code that I
wrote, but I keep getting the an error.
This is the example code:
/input,start80,NASTRAN,'C:\Program Files\Ansys
Inc\v80\ANSYS\apdl\',,,,,,,,,,,,,,,,1
This is what I wrote:
F=input,startt80,Nastran,'C:\Program
Files\UGS\NXNastran\5.0\bin\Nastran.exe',,,,,,,,,,,,,,,,1 %The path
to run NASTRAN.exe
F
I defined the variable as F because I didn't think that Matlab would
recgonize the "/"
If there is a simpler way to run an excutable program within
Matlab...please let me know.
You can find more about "!" in the help by searching for "bang". It
should be the second entry listed. If you cannot find it there then
type "doc system". It will be the in the See Also list of functions
at the bottom.
Jeremy Smith wrote:
>
>
> Try "!"
>
> You can find more about "!" in the help by searching for "bang".
> It
> should be the second entry listed. If you cannot find it there
> then
> type "doc system". It will be the in the See Also list of
> functions
> at the bottom.
Does MatLab have a command or maybe there is a way that I could write
a function that once I run this other program, I could then get
MatLab to supply the correct input file. Once I run the excutable for
the other program, the program ask for the user to specify the file
that they would like to run. I am going to be doing opening and
reopening this excutable and subsequent open file screen multiple
times. Is there a way that I can tell matlab to keep supplying the
same file name once I excute the bang command and run the other file?
I was thinking that I would have to write a function that places a
certain file into the open file window then excutes that command. Is
that possible?
It all depends on the program you must run. As far as I know the
only way to have a program do what you want it to do from Matlab
itself the program must be able to accept command line inputs. I
suspect (and could be wrong) any other method, aside from the command
line, would involve Java. If, however, your program does accept
command lines you can use "eval" along with "!".
"Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message
news:ef5c942.2@webcrossing.raydaftYaTP...
> It all depends on the program you must run. As far as I know the
> only way to have a program do what you want it to do from Matlab
> itself the program must be able to accept command line inputs. I
> suspect (and could be wrong) any other method, aside from the command
> line, would involve Java. If, however, your program does accept
> command lines you can use "eval" along with "!".
>
> FileName = 'C:\File Location\File_Name';
> eval(['! "C:\Program Files\SomeProgram\executable.exe" "' FileName
> '"])
Don't use EVAL -- you don't need to in this case. Use SYSTEM, DOS, or UNIX
instead of !.
Steven Lord wrote:
>
>
>
> "Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message
> news:ef5c942.2@webcrossing.raydaftYaTP...
>> It all depends on the program you must run. As far as I know
the
>> only way to have a program do what you want it to do from
Matlab
>> itself the program must be able to accept command line inputs.
I
>> suspect (and could be wrong) any other method, aside from the
> command
>> line, would involve Java. If, however, your program does accept
>> command lines you can use "eval" along with "!".
>>
>> FileName = 'C:\File Location\File_Name';
>> eval(['! "C:\Program Files\SomeProgram\executable.exe" "'
> FileName
>> '"])
>
> Don't use EVAL -- you don't need to in this case. Use SYSTEM, DOS,
> or UNIX
> instead of !.
>
>
> theprogram = '"C:\Program Files\SomeProgram\executable.exe"';
> thearguments = 'foo bar';
> system(sprintf('%s %s', theprogram thearguments))
>
>
> --
> Steve Lord
> slord@mathworks.com
>
>
> What is the 'foo bar' command? Is 'foo bar' the file that I want to
open?
Steven Lord wrote:
> "Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message
> news:ef5c942.2@webcrossing.raydaftYaTP...
> > It all depends on the program you must run. As far as I know the
> > only way to have a program do what you want it to do from Matlab
> > itself the program must be able to accept command line inputs. I
> > suspect (and could be wrong) any other method, aside from the command
> > line, would involve Java. If, however, your program does accept
> > command lines you can use "eval" along with "!".
> >
> > FileName = 'C:\File Location\File_Name';
> > eval(['! "C:\Program Files\SomeProgram\executable.exe" "' FileName
> > '"])
>
> Don't use EVAL -- you don't need to in this case. Use SYSTEM, DOS, or UNIX
> instead of !.
>
>
> theprogram = '"C:\Program Files\SomeProgram\executable.exe"';
> thearguments = 'foo bar';
> system(sprintf('%s %s', theprogram thearguments))
I'm not often one to try to amplify posts from Steven Lord, but...
I find the best way to develop this kind of stuff is to use the
following approach:
1) Create your command string using sprintf and/or old-style ML
concatenations.
2) View it.
3) When absolutely sure it's right, system() it.
This generally leaves the following code:
command = sprintf( % Some stuff
system(command)
I know this seems really trivial, but wrapping system() around
something you're not yet sure about could cause nasal demons...
What is the difference between 'system' and '!' besides 'system'
returning results?
Why is there such a strong aversion to using 'eval'? I realize there
is usually a better way of accomplishing the task programmatically
but I tend to see fairly strong opposition to using 'eval' overall.
> What is the difference between 'system' and '!' besides 'system'
> returning results?
>
> Why is there such a strong aversion to using 'eval'? I realize there
> is usually a better way of accomplishing the task programmatically
> but I tend to see fairly strong opposition to using 'eval' overall.
Since the string to be eval'd is built dynamically, the MATLAB engine
can't accelerate anything containing an eval. In fact, even the
parsing of the string has to happen as the eval is called, rather
than the entire m-file being preparsed.
There used to be serious issues with the compiler and eval. I think
that stuff has been resolved with the new compiler, but I don't know.
Finally, readability suffers. String concatenation, number-to-string
conversion (also affects performance!), double and quadruple quotes,
etc.
Code that passes through CSSM that uses eval usually indicates one of
several problems:
- Intuitive desire to use sequentially named variables. (Do other
languages like VBasic use this?) Cell arrays are almost always the
best thing to use instead, for performance and readability reasons.
- Not understanding "command/function duality", which lets you replace
"load fname" with "load('fname')"
- Not understanding the difference between literal strings and string
variables (I think related to the former)
So there have it. Computationally slow, hard to read/write/maintain,
indicator of deeper programming knowledge issues which I like to think I
can help address.
"Ender" <jr147@msstate.edu> wrote in message
news:ef5c942.4@webcrossing.raydaftYaTP...
> Steven Lord wrote:
*snip*
>> Don't use EVAL -- you don't need to in this case. Use SYSTEM, DOS,
>> or UNIX
>> instead of !.
>>
>>
>> theprogram = '"C:\Program Files\SomeProgram\executable.exe"';
>> thearguments = 'foo bar';
>> system(sprintf('%s %s', theprogram thearguments))
>>
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>>
>>
>> What is the 'foo bar' command? Is 'foo bar' the file that I want to
> open?
Foo and bar are just 'dummy' arguments. I wanted to show how to pass
arguments to the executable.exe that you wanted to call using ! or system,
so I used them as placeholder arguments.
"Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message
news:ef5c942.6@webcrossing.raydaftYaTP...
> What is the difference between 'system' and '!' besides 'system'
> returning results?
Anything, including % (which normally act as comment characters) that
appears after ! on the command line or on a line of a script or a function
is passed verbatim to the system. In this example, it's as though you typed
"callFoo % This attempts to call the callFoo function" (without the quotes)
at the system command prompt.
!callFoo % This attempts to call the callFoo function
With SYSTEM, you control exactly what gets passed to the system. This
example just passes "callFoo" to the system to be executed.
system('callFoo') % This attempts to call the callFoo function
> Why is there such a strong aversion to using 'eval'? I realize there
> is usually a better way of accomplishing the task programmatically
> but I tend to see fairly strong opposition to using 'eval' overall.
In my opinion (and the opinions of lots of other posters) it's much harder
to read something like:
n = 10;
eval(sprintf('a%d = 1:%d', n, n))
than to read:
a{n} = 1:n
EVAL can also be a very good code obfuscation tool.
Ralph Schleicher:
<SNIP a very seasoned CSSMer fighting for <eval>...
> And another one, a Matlab lexer:
> function tok = mlex(str)
> eval(['mlex1 ', str, ' ;']);
> % It's magic!
> tok = ans;
> function arg = mlex1(varargin)
> arg = varargin;
> The lexer is my favorite, took me some time to work it out...
hmmmm...
% let's put this code into <mlex.m>
% run
mlex 'this is a test'
% ans = 'this' 'is' 'a' 'test'
% -but-
strread('this is a test','%s').'
% ans = 'this' 'is' 'a' 'test'
most likely, however, i'm missing something...
best from zurich
urs
Furthermore problems with mlex (which is a nice party trick, I admit):
>> mlex 'asd b sdf sd f'
ans =
'asd' 'b' 'sdf' 'sd' 'f'
% So far so good, but ...
% semicolons, single quotes, commas and percent markers all cause mlex to
break:
>> mlex 'asd b sdf sd f; sdfa'
??? Error using ==> eval
Undefined function or variable 'sdfa'.
Error in ==> mlex at 2
eval(['mlex1 ', str, ' ;']);
>> mlex 'asd b sdf sd f'' sdfa'
??? Error: A MATLAB string constant is not terminated properly.
Error in ==> mlex at 2
eval(['mlex1 ', str, ' ;']);
>> mlex 'asd b sdf sd f, sdfa'
ans =
'asd' 'b' 'sdf' 'sd' 'f'
??? Error using ==> eval
Undefined function or variable 'sdfa'.
Error in ==> mlex at 2
eval(['mlex1 ', str, ' ;']);
>> mlex 'asd b sdf sd f% sdfa'
ans =
'asd' 'b' 'sdf' 'sd' 'f'
ans =
'asd' 'b' 'sdf' 'sd' 'f'
------------------
Also, try this:
>> str = ['a b c; ' char(13) 'quit']
>> mlex(str)
I hope no one is using MLEX to implement a CGI script ...
--
Gautam Vallabha
The MathWorks
Email: Gautam.Vallabha@mathworks.com
"us" <us@neurol.unizh.ch> wrote in message
news:ef5c942.12@webcrossing.raydaftYaTP...
> Ralph Schleicher:
> <SNIP a very seasoned CSSMer fighting for <eval>...
>
>
> % let's put this code into <mlex.m>
> % run
> mlex 'this is a test'
> % ans = 'this' 'is' 'a' 'test'
>
> % -but-
> strread('this is a test','%s').'
> % ans = 'this' 'is' 'a' 'test'
>
> most likely, however, i'm missing something...
> best from zurich
> urs
>
> ps: just one of the counter-examples... :-)
i did <it> - and - oh my G... ML <quit>... why!?
i must say you're one nasty fellow, <gautam>...
but fortunately, <us>'s solution yields a user-friendly
s=['a b c; ' char(13) 'quit'].';
strread(s,'%s').'
% ans = 'a' 'b' 'c;' 'quit'
> hmmmm...
>
> % let's put this code into <mlex.m>
> % run
> mlex 'this is a test'
> % ans = 'this' 'is' 'a' 'test'
>
> % -but-
> strread('this is a test','%s').'
> % ans = 'this' 'is' 'a' 'test'
>
> most likely, however, i'm missing something...
Yes, you do. Try this:
mlex('foo -bar ''baz'' [1 2; 3 4]')
Now imagine you want to parse a configuration file of the form
move -x 650 -y 50
signal -newline -anchor '=' -string 'Ma =@#.###'
signal -newline -anchor '=' -string 'p_{amb} =@#.### bar' -tex
signal -newline -anchor '=' -string 'T_{amb} =@###.# °C' -tex
tok = mlex(input_line);
command = tok{1};
tok(1) = [];
% Sanity checks..., then
feval(['do_', command], tok{:});
I have another question. I tried the command that someone stated
earlier to run another program through MatLab. My program that I am
trying to run can be run through the M-Dos prompt to answer the
question that someone stated earlier. My lines of code look like
this.
Whenever I try to run this code in my program, the entire program
will complete a run, but the lines of code to open this above stated
file does not. I get this error on the command screen.
Also is there a way that I can tell MatLab to open 'foo.exe'
regardless of the path. That way when I compile my program then send
it to another computer I won't have to rewrite the path to the
'file.exe'
I was thinking that maybe there was a search and find command in
MatLab
"Ender" <jr147@msstate.edu> wrote in message
news:ef5c942.16@webcrossing.raydaftYaTP...
>I have another question. I tried the command that someone stated
> earlier to run another program through MatLab. My program that I am
> trying to run can be run through the M-Dos prompt to answer the
> question that someone stated earlier. My lines of code look like
> this.
>
> Ex.
>
> FileName='D:\Program File\path\path\foo.txt';
> eval(['! "C:\Program Files\path\path\path\path\foo.exe" "
> FileName"']);
EVAL and ! are the wrong tools for this job.
> Whenever I try to run this code in my program, the entire program
> will complete a run, but the lines of code to open this above stated
> file does not. I get this error on the command screen.
>
> *** USER FATAL MESSAGE (pgm: nastran, fn: main)
> jid=FileName (command line[1])
>
> This file does not exist.
You're calling foo.exe with the string "FileName" as the input. In order to
call the function with the contents of the FileName variable as input, use:
> Also is there a way that I can tell MatLab to open 'foo.exe'
> regardless of the path. That way when I compile my program then send
> it to another computer I won't have to rewrite the path to the
> 'file.exe'
If foo.exe is on your system path (which is distinct from the MATLAB path),
SYSTEM should be able to call it.
You have to end the '' string in order to have a variable's
value concatenated on by the [] operator. Your current
expression is equivilent to not having the [] there at all and just
having one long '' string.
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes
us wrote:
>
>
> Ender:
> <SNIP from ML to OS...
>
>> What do mean by system path...
>
> it's the <search path> of your operating system (OS), eg,
> windows 95, dos 3.1, etc - or - the OS's equivalent of ML's
> <path>...
>
> see
>
> help getenv;
> % -and- in particular
> getenv('PATH')
>
> us
I am still confused about this. I typed in the above command in the
MatLab command window. When I hit enter I got this :
plust alot more subdirectories. I don't understand what this means or
what this is telling me. Does this system path allow me to find the
path to a file regardless of the path. Meaning if I am looking for a
certain program on a computer that is different from mine, as long as
I state the file that I am looking for will MatLab look through the
computer until it finds the file, or do I have to specify the path?
us wrote:
>
>
> Ender:
> <SNIP from ML to OS...
>
>> What do mean by system path...
>
> it's the <search path> of your operating system (OS), eg,
> windows 95, dos 3.1, etc - or - the OS's equivalent of ML's
> <path>...
>
> see
>
> help getenv;
> % -and- in particular
> getenv('PATH')
>
> us
I am still confused about this. I typed in the above command in the
MatLab command window. When I hit enter I got this :
plust alot more subdirectories. I don't understand what this means or
what this is telling me. Does this system path allow me to find the
path to a file regardless of the path. Meaning if I am looking for a
certain program on a computer that is different from mine, as long as
I state the file that I am looking for will MatLab look through the
computer until it finds the file, or do I have to specify the path?
"Ender" <jr147@msstate.edu> wrote in message
news:ef5c942.21@webcrossing.raydaftYaTP...
> us wrote:
>>
>>
>> Ender:
>> <SNIP from ML to OS...
>>
>>> What do mean by system path...
>>
>> it's the <search path> of your operating system (OS), eg,
>> windows 95, dos 3.1, etc - or - the OS's equivalent of ML's
>> <path>...
>>
>> see
>>
>> help getenv;
>> % -and- in particular
>> getenv('PATH')
>>
>> us
>
>
> I am still confused about this. I typed in the above command in the
> MatLab command window. When I hit enter I got this :
>
> C:\MATLAB7\bin\win32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system3
> 2\wbem;c:\program files\ivi\bin...
>
> plust alot more subdirectories. I don't understand what this means or
> what this is telling me. Does this system path allow me to find the
> path to a file regardless of the path.
If the executable that you want to execute is in a directory that is on your
system path, then you will not need to provide the full path to that
executable when you use the SYSTEM function or run it from the Windows
command line. To borrow the Wikipedia definition, your system path is the
set of directories where your computer's operating system will search for
executables.
For instance, you probably have an executable write.exe in your
c:\windows\system32 directory. Because this directory is on your system
path, you can use this command to execute it:
system('write')
instead of needing to use:
system('c:\windows\system32\write')
Windows will search each directory in your system path until it finds a file
named write, and will execute that program when Windows finds it in one of
those directories.
"Steven Lord" <slord@mathworks.com> wrote in message <f85dmk$p12$1@fred.mathworks.com>...
>
> "Ender" <jr147@msstate.edu> wrote in message
> news:ef5c942.21@webcrossing.raydaftYaTP...
> > us wrote:
> >>
> >>
> >> Ender:
> >> <SNIP from ML to OS...
> >>
> >>> What do mean by system path...
> >>
> >> it's the <search path> of your operating system (OS), eg,
> >> windows 95, dos 3.1, etc - or - the OS's equivalent of ML's
> >> <path>...
> >>
> >> see
> >>
> >> help getenv;
> >> % -and- in particular
> >> getenv('PATH')
> >>
> >> us
> >
> >
> > I am still confused about this. I typed in the above command in the
> > MatLab command window. When I hit enter I got this :
> >
Try
winopen('C:\.....abc.exe');
> > C:\MATLAB7\bin\win32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system3
> > 2\wbem;c:\program files\ivi\bin...
> >
> > plust alot more subdirectories. I don't understand what this means or
> > what this is telling me. Does this system path allow me to find the
> > path to a file regardless of the path.
>
> If the executable that you want to execute is in a directory that is on your
> system path, then you will not need to provide the full path to that
> executable when you use the SYSTEM function or run it from the Windows
> command line. To borrow the Wikipedia definition, your system path is the
> set of directories where your computer's operating system will search for
> executables.
>
> For instance, you probably have an executable write.exe in your
> c:\windows\system32 directory. Because this directory is on your system
> path, you can use this command to execute it:
>
> system('write')
>
> instead of needing to use:
>
> system('c:\windows\system32\write')
>
> Windows will search each directory in your system path until it finds a file
> named write, and will execute that program when Windows finds it in one of
> those directories.
>
> --
> Steve Lord
> slord@mathworks.com
>
>
I tried this above command with the excutable that I was trying to
run and it didn't work. MatLab said that
??? Error using ==> winopen
The specified file does not exist.
>> If the executable that you want to execute is in a directory
that
> is on your
>> system path, then you will not need to provide the full path to
> that
>> executable when you use the SYSTEM function or run it from the
> Windows
>> command line. To borrow the Wikipedia definition, your system
> path is the
>> set of directories where your computer's operating system will
> search for
>> executables.
>>
>> For instance, you probably have an executable write.exe in your
>> c:\windows\system32 directory. Because this directory is on
your
> system
>> path, you can use this command to execute it:
>>
>> system('write')
>>
>> instead of needing to use:
>>
>> system('c:\windows\system32\write')
>>
>> Windows will search each directory in your system path until it
> finds a file
>> named write, and will execute that program when Windows finds
it
> in one of
>> those directories.
>>
Windows must first know which path to search in to find the file? I
can't just type system('write.exe') without first initially stating
where foo.exe is. So when you say "Windows will search each directory
in your system path until it
> finds a file
>> named "write" I would first have to state the correct path to
write.exe. There is no command that lets me just state the file
without first stating the path to the file?
Ender <jr147@msstate.edu> wrote in message
<ef5c942.25@webcrossing.raydaftYaTP>...
> > Try
> > winopen('C:\.....abc.exe');
>
> I tried this above command with the excutable that I was
trying to
> run and it didn't work. MatLab said that
>
> ??? Error using ==> winopen
> The specified file does not exist.
>
> >> If the executable that you want to execute is in a
directory
> that
> > is on your
> >> system path, then you will not need to provide the
full path to
> > that
> >> executable when you use the SYSTEM function or run it
from the
> > Windows
> >> command line. To borrow the Wikipedia definition, your
system
> > path is the
> >> set of directories where your computer's operating
system will
> > search for
> >> executables.
> >>
> >> For instance, you probably have an executable
write.exe in your
> >> c:\windows\system32 directory. Because this directory
is on
> your
> > system
> >> path, you can use this command to execute it:
> >>
> >> system('write')
> >>
> >> instead of needing to use:
> >>
> >> system('c:\windows\system32\write')
> >>
> >> Windows will search each directory in your system path
until it
> > finds a file
> >> named write, and will execute that program when
Windows finds
> it
> > in one of
> >> those directories.
> >>
>
> Windows must first know which path to search in to find
the file? I
> can't just type system('write.exe') without first
initially stating
> where foo.exe is. So when you say "Windows will search
each directory
> in your system path until it
> > finds a file
> >> named "write" I would first have to state the correct
path to
> write.exe. There is no command that lets me just state
the file
> without first stating the path to the file?
>
> -Ender-
I have been trying to execute this program for matlab using
the advice above but I keep getting this error:
As a stylistic note: if you use [] to splice together character
strings on the lines above this, but then use sprintf to splice
together character strings here, then it may give the onlooker
the impression that there is something different about the
respective operations, and the onlooker may then waste time trying
to figure out what the distinction in meaning is. It is thus
advisable to be consistant, such as by coding
cmdLine = [icExe, ' ', cmdLine];
instead of using the sprintf.
>[status,result] = system(cmdLine)
>Any help on why this doesnt work?
There is nothing that is obvious to me in what you show.
However, not knowing the starting values of FullImg, FullSens, or FullAA,
I would speculate that perhaps one of them has a special character
(such as a space or '>') that needs to be quoted to be passed intact
to the command line. Possibly something like,
FullImg = ['-i', ' "', FullImg, '" '];
--
"You can't hit what you can't see." -- Walter "The Big Train" Johnson
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fq9fb8$s9b$1@canopus.cc.umanitoba.ca>...
> In article <fq9esh$ojv$1@fred.mathworks.com>,
> Josh <imahorse3@hotmail.com> wrote:
>
> >I have been trying to execute this program for matlab
using
> >the advice above but I keep getting this error:
>
> >status =
> > 128
> >result =
> > ''
>
> >icExe = 'C:\PathName\myProgram.exe';
> >FullImg = ['-i', ' ', FullImg, ' '];
> >FullSens = ['-bi', ' ', FullSens, ' '];
> >FullAA = ['-co', ' ', FullAA, ' '];
>
> >cmdLine = [FullImg, FullSens, FullAA];
> >cmdLine = sprintf('%s %s', icExe, cmdLine)
>
> As a stylistic note: if you use [] to splice together
character
> strings on the lines above this, but then use sprintf to
splice
> together character strings here, then it may give the
onlooker
> the impression that there is something different about the
> respective operations, and the onlooker may then waste
time trying
> to figure out what the distinction in meaning is. It is
thus
> advisable to be consistant, such as by coding
>
> cmdLine = [icExe, ' ', cmdLine];
>
> instead of using the sprintf.
>
>
> >[status,result] = system(cmdLine)
>
> >Any help on why this doesnt work?
>
> There is nothing that is obvious to me in what you show.
> However, not knowing the starting values of FullImg,
FullSens, or FullAA,
> I would speculate that perhaps one of them has a special
character
> (such as a space or '>') that needs to be quoted to be
passed intact
> to the command line. Possibly something like,
>
> FullImg = ['-i', ' "', FullImg, '" '];
> --
> "You can't hit what you can't see." -- Walter "The Big
Train" Johnson
OK, I will take your advice about the style, thanks.
The 3 variables (FullImg, FullSens, FullAA) are simply
pathname\filename combinations as selected by the user.
An example: FullImg = C:\Users\joshua\ic\testcase\eglin.img
"Josh " <imahorse3@hotmail.com> wrote in message
<fq9frt$aqp$1@fred.mathworks.com>...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> message <fq9fb8$s9b$1@canopus.cc.umanitoba.ca>...
> > In article <fq9esh$ojv$1@fred.mathworks.com>,
> > Josh <imahorse3@hotmail.com> wrote:
> >
> > >I have been trying to execute this program for matlab
> using
> > >the advice above but I keep getting this error:
> >
> > >status =
> > > 128
> > >result =
> > > ''
> >
> > >icExe = 'C:\PathName\myProgram.exe';
> > >FullImg = ['-i', ' ', FullImg, ' '];
> > >FullSens = ['-bi', ' ', FullSens, ' '];
> > >FullAA = ['-co', ' ', FullAA, ' '];
> >
> > >cmdLine = [FullImg, FullSens, FullAA];
> > >cmdLine = sprintf('%s %s', icExe, cmdLine)
> >
> > As a stylistic note: if you use [] to splice together
> character
> > strings on the lines above this, but then use sprintf
to
> splice
> > together character strings here, then it may give the
> onlooker
> > the impression that there is something different about
the
> > respective operations, and the onlooker may then waste
> time trying
> > to figure out what the distinction in meaning is. It is
> thus
> > advisable to be consistant, such as by coding
> >
> > cmdLine = [icExe, ' ', cmdLine];
> >
> > instead of using the sprintf.
> >
> >
> > >[status,result] = system(cmdLine)
> >
> > >Any help on why this doesnt work?
> >
> > There is nothing that is obvious to me in what you show.
> > However, not knowing the starting values of FullImg,
> FullSens, or FullAA,
> > I would speculate that perhaps one of them has a
special
> character
> > (such as a space or '>') that needs to be quoted to be
> passed intact
> > to the command line. Possibly something like,
> >
> > FullImg = ['-i', ' "', FullImg, '" '];
> > --
> > "You can't hit what you can't see." -- Walter "The
Big
> Train" Johnson
>
>
Nevermind, I had to change the environment variables on my
system. Duh.
On Fri, 29 Feb 2008 13:50:23 -0500, Josh <imahorse3@hotmail.com> wrote:=
> "Josh " <imahorse3@hotmail.com> wrote in message
> <fq9frt$aqp$1@fred.mathworks.com>...
>> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
>> message <fq9fb8$s9b$1@canopus.cc.umanitoba.ca>...
>> > In article <fq9esh$ojv$1@fred.mathworks.com>,
>> > Josh <imahorse3@hotmail.com> wrote:
>> >
>> > >I have been trying to execute this program for matlab
>> using
>> > >the advice above but I keep getting this error:
>> >
>> > >status =3D
>> > > 128
>> > >result =3D
>> > > ''
>> >
>> > >icExe =3D 'C:\PathName\myProgram.exe';
>> > >FullImg =3D ['-i', ' ', FullImg, ' '];
>> > >FullSens =3D ['-bi', ' ', FullSens, ' '];
>> > >FullAA =3D ['-co', ' ', FullAA, ' '];
>> >
>> > >cmdLine =3D [FullImg, FullSens, FullAA];
>> > >cmdLine =3D sprintf('%s %s', icExe, cmdLine)
>> >
>> > As a stylistic note: if you use [] to splice together
>> character
>> > strings on the lines above this, but then use sprintf
> to
>> splice
>> > together character strings here, then it may give the
>> onlooker
>> > the impression that there is something different about
> the
>> > respective operations, and the onlooker may then waste
>> time trying
>> > to figure out what the distinction in meaning is. It is
>> thus
>> > advisable to be consistant, such as by coding
>> >
>> > cmdLine =3D [icExe, ' ', cmdLine];
>> >
>> > instead of using the sprintf.
>> >
>> >
>> > >[status,result] =3D system(cmdLine)
>> >
>> > >Any help on why this doesnt work?
>> >
>> > There is nothing that is obvious to me in what you show.
>> > However, not knowing the starting values of FullImg,
>> FullSens, or FullAA,
>> > I would speculate that perhaps one of them has a
> special
>> character
>> > (such as a space or '>') that needs to be quoted to be
>> passed intact
>> > to the command line. Possibly something like,
>> >
>> > FullImg =3D ['-i', ' "', FullImg, '" '];
>> > --
>> > "You can't hit what you can't see." -- Walter "The
> Big
>> Train" Johnson
>>
>>
> Nevermind, I had to change the environment variables on my
> system. Duh.
>
> Thanks anyway.
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.