Pass arguments to a .bat file from matlab

Hi guys, I know how to run a file .bat from matlab (!file.bat), but I have to pass some parameters (such as variables or string file) to this file and then I have to run it....how can I do?
Thank you to all!!

 Accepted Answer

This seems to work.
Create this TestBat.bat file
@echo off
echo This is a test.
echo %1
Run this in MATLAB
!TestBat abcdefg
You got:
This is a test.
abcdefg

3 Comments

Sorry, I have a new problem. I have this char variable: name='file.pdf';
when I do !test name
I see in the file test.bat "name", that is the container of the variabile but not the content of the variable.....I need to pass the content name.pdf to the file test.bat.
How can I resolve??
In MATLAB, write script like this:
name='file.pdf';
CmdStr=sprintf('test %s',name);
system(CmdStr);

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!