The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matlab says that the command is too long to execute
Replies: 3   Last Post: Jun 10, 2011 1:04 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 33
Registered: 3/21/08
Re: Matlab says that the command is too long to execute
Posted: Jun 10, 2011 12:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello Steve Lord,

Thanks a lot for your feedback. It is exceeding the limit allowed by DOS!! I have two questions for you:

1. Can I send this data as a bin file to the Python program? As far as I have seen, the python command only accepts a string, e.g, in the following command:


If num2 is anything apart from a string, Matlab shows an error. I want to know if a bin file will also work.

2. I am currently trying to convert my array to a bin file. I am using the following command:

fid = fopen('nazmul.bin','wb'); // opening a bin file
fwrite(fid,array1); // array1 is the array that I want to send to Python

However, it's not working properly. When I read the 'nazmul.bin' file, I find the output array to be completely blank.

fid = fopen('nazmul.bin','wb');

I find A to be an empty array. Ideally, I would like A to be equal to array1. Can you please suggest what mistakes I am making here?

Thanks a lot,


"Steven_Lord" <> wrote in message <ist9fk$m3h$>...
> "Nazmul Islam" <> wrote in message
> news:isr8oi$8ir$

> > I am calling a Python program from Matlab and passing an array to the
> > program. I am using the following steps:
> >
> > % Let us assume some random array
> > num1 = ones(1,100);
> > % I am forced to pass parameters as string due to the Matlab-Python
> > interaction.
> > num2 = num2str(num1);
> > % The function is saved in a Python program called
> > z=python('',num2);
> >
> > The program works find when the size of num1 is small (e.g. 100). However,
> > when it large, e.g., 500000, Matlab shows the following error:
> >
> > ??? Error using ==> dos
> > The command is too long to execute.
> >
> > Error in ==> python at 68
> > [status, result] = dos(pythonCmd);
> >
> > Does anyone know how to fix this error?

> Set a breakpoint on line 68 of python.m and look at the length of the
> command string constructed by the python function that is being passed into
> the DOS function. It likely exceeds the limit allowed by the DOS function on
> your operating system.
> How to correct the problem would depend on what the python function does to
> construct the command, so you'll likely need to ask the author of the python
> function for help.
> --
> Steve Lord
> To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.