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

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com