Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
start matlab in linux shell without startup message and prompt

Subject: start matlab in linux shell without startup message and prompt

From: Le He

Date: 1 Oct, 2009 15:40:17

Message: 1 of 2

Hi,
in bash I like to pipe some expression to matlab:
$ result=$(echo "3+3"|matlab)
$ echo $result
Warning: No display specified. You will not be able to display graphics on the screen. < M A T L A B (R) > Copyright 1984-2008 The MathWorks, Inc. Version 7.6.0.324 (R2008a) February 10, 2008 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. Warning: Name is nonexistent or not a directory: /matlab. > In path at 110 In startup at 4 In matlabrc at 272 Warning: Name is nonexistent or not a directory: /toolbox. > In path at 110 In startup at 15 In matlabrc at 272 >> ans = 6 >>

But I don't want the message and prompt in the result variable. So is there any way to make result just store 6, e.e.
$ echo $result
6

Thanks and regards!

Subject: start matlab in linux shell without startup message and prompt

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 1 Oct, 2009 17:08:56

Message: 2 of 2

Le He <flylehe@hotmail.com> wrote:
> Hi,
> in bash I like to pipe some expression to matlab:
> $ result=$(echo "3+3"|matlab)
> $ echo $result
> Warning: No display specified. You will not be able to display graphics
on the screen. < M A T L A B (R) > Copyright 1984-2008 The MathWorks, Inc.
Version 7.6.0.324 (R2008a) February 10, 2008 To get started, type one of
these: helpwin, helpdesk, or demo. For product information, visit
www.mathworks.com. Warning: Name is nonexistent or not a directory:
/matlab. > In path at 110 In startup at 4 In matlabrc at 272 Warning: Name
is nonexistent or not a directory: /toolbox. > In path at 110 In startup at
15 In matlabrc at 272 >> ans = 6 >>
>
> But I don't want the message and prompt in the result variable. So is
there any way to make result just store 6, e.e.
> $ echo $result
> 6
>

There are many ways. I am sure plenty are tidier than this one:

cow-lx 15% bash
bash-2.05b$ result=$(echo "disp(sprintf('\\n%0.6g',3+3)),quit" \
> | matlab -nodisplay -nojvm | tail -1)
bash-2.05b$ echo $result
6
bash-2.05b$ exit
exit
cow-lx 16%


Note that the backslash is to continue the command onto the next line, and
that the > on the next line is the prompt for me to continue.

I used disp(sprintf()) to get the answer on a line by itself.



--
Dr Tristram J. Scott
Energy Consultant

Tags for this Thread

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.

Contact us