|
|
Run an exe file from matlab
I have a program called dcm2nii.exe and in order to run it I need to include input arguments. How can I do this automatically through matlab??
When just using cmd here's what I do:
cd C:\Documents and Settings\Administrator\Desktop\Ali\mricron
dcm2nii -o C:\Vesta C:\Vesta (where dcm2nii is the exe file, -o C:\Vesta and C:\Vesta are two input arguments)
I'm really new to using matlab so if you could help me out step by step I'd really appreciate it!
|
|
0
|
|
|
|
Reply
|
Ali
|
5/10/2010 5:31:20 PM |
|
"Ali Culp" <aliculp@hotmail.com> wrote in message <hs9ft8$6k0$1@fred.mathworks.com>...
> I have a program called dcm2nii.exe and in order to run it I need to include input arguments. How can I do this automatically through matlab??
>
> When just using cmd here's what I do:
> cd C:\Documents and Settings\Administrator\Desktop\Ali\mricron
> dcm2nii -o C:\Vesta C:\Vesta (where dcm2nii is the exe file, -o C:\Vesta and C:\Vesta are two input arguments)
>
> I'm really new to using matlab so if you could help me out step by step I'd really appreciate it!
a hint:
- this has been discussed the other day...
http://www.mathworks.com/matlabcentral/newsreader/view_thread/281645
us
|
|
0
|
|
|
|
Reply
|
us
|
5/10/2010 5:45:12 PM
|
|
I've tried using that code but am getting a few error messages along the way...
For fprintf('%s %s %s',fid,s1,s2) (where s1/s2 are my two input parameters), it changes my command line such that:
-o C:\Vesta C:\Vesta>>
is what is looks like. Then when I type fclose(fid) it says invalid fid.
Also, when I type the system(['C:\Documents and Settings\Administrator\Desktop\Ali\mricron\dcm2nii.exe<'fname]) it says I'm missing a matlab operator at the fname section.
|
|
0
|
|
|
|
Reply
|
Ali
|
5/10/2010 6:22:23 PM
|
|
On May 11, 6:22=A0am, "Ali Culp" <alic...@hotmail.com> wrote:
> I've tried using that code but am getting a few error messages along the =
way...
>
> For fprintf('%s %s %s',fid,s1,s2) (where s1/s2 are my two input parameter=
s), it changes my command line such that:
>
> -o C:\Vesta C:\Vesta>>
>
> is what is looks like. Then when I type fclose(fid) it says invalid fid.
>
> Also, when I type the system(['C:\Documents and Settings\Administrator\De=
sktop\Ali\mricron\dcm2nii.exe<'fname]) it says I'm missing a matlab operato=
r at the fname section.
Well why not simply reproduce exactly what you do in DOS?
system('dcm2nii -o C:\Vesta C:\Vesta')
This assumes you have dcm2nii in the path.
If not, then assuming dcm2nii.exe is in the directory, you could do
this:
pgm=3D'"C:\Documents and Settings\Administrator\Desktop\Ali\mricron
\dcm2nii"';
then:
system([pgm ' -o C:\Vesta C:\Vesta'])
Note: I think you'll need double quotes because of the spaces in the
directory name.
|
|
0
|
|
|
|
Reply
|
TideMan
|
5/10/2010 7:57:31 PM
|
|
> Well why not simply reproduce exactly what you do in DOS?
> system('dcm2nii -o C:\Vesta C:\Vesta')
> This assumes you have dcm2nii in the path.
> If not, then assuming dcm2nii.exe is in the directory, you could do
> this:
> pgm='"C:\Documents and Settings\Administrator\Desktop\Ali\mricron
> \dcm2nii"';
> then:
> system([pgm ' -o C:\Vesta C:\Vesta'])
> Note: I think you'll need double quotes because of the spaces in the
> directory name.
The problem is there are TWO commands that I have to give DOS...the first is to change where it's looking for the file >>cd C:\Documents...\mricron and the second is to tell it to run the dcm2nii program >>dcm2nii -o C:\Vesta C:\Vesta. Is there a way that I can do something like this in matlab: >>system('command 1','command 2')? If so let me know how!!
|
|
0
|
|
|
|
Reply
|
Ali
|
5/10/2010 8:53:05 PM
|
|
On May 11, 8:53=A0am, "Ali Culp" <alic...@hotmail.com> wrote:
> > Well why not simply reproduce exactly what you do in DOS?
> > system('dcm2nii -o C:\Vesta C:\Vesta')
> > This assumes you have dcm2nii in the path.
> > If not, then assuming dcm2nii.exe is in the directory, you could do
> > this:
> > pgm=3D'"C:\Documents and Settings\Administrator\Desktop\Ali\mricron
> > \dcm2nii"';
> > then:
> > system([pgm ' -o C:\Vesta C:\Vesta'])
> > Note: I think you'll need double quotes because of the spaces in the
> > directory name.
>
> The problem is there are TWO commands that I have to give DOS...the first=
is to change where it's looking for the file >>cd C:\Documents...\mricron =
and the second is to tell it to run the dcm2nii program >>dcm2nii -o C:\Ves=
ta C:\Vesta. Is there a way that I can do something like this in matlab: >>=
system('command 1','command 2')? If so let me know how!!
Well, you can cd in Matlab first, do your calcs, then cd back:
oldpth=3Dpwd;
cd('C:\Documents...\mricron')
system('dcm2nii -o C:\Vesta C:\Vesta')
cd(oldpth)
|
|
0
|
|
|
|
Reply
|
TideMan
|
5/10/2010 9:11:39 PM
|
|
Wow so simple.
Thanks!
|
|
0
|
|
|
|
Reply
|
Ali
|
5/10/2010 10:28:09 PM
|
|
"Ali Culp" wrote in message <hsa19p$dr6$1@fred.mathworks.com>...
> Wow so simple.
> Thanks!
I need to run an .exe file which requires a xml file as an input. Can you please tell me how to run the exe file from MATLAB so that it is able to take that xml file as an input.
Thanks in advance !!
Kamlesh
|
|
0
|
|
|
|
Reply
|
K
|
1/9/2011 11:46:04 PM
|
|
|
7 Replies
247 Views
(page loaded in 0.082 seconds)
|
|
|
|
|
|
|
|
|