Got Questions? Get Answers.
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:
no standalone apps output in console

Subject: no standalone apps output in console

From: Michal Kvasnicka

Date: 1 Feb, 2013 17:36:08

Message: 1 of 6

I have function:
========================================
function m = magicsquare1(n)
%MAGICSQUARE generates a magic square matrix of the size
% specified by the input parameter n.

% Copyright 2003-2012 The MathWorks, Inc.

if ischar(n)
    n=str2num(n);
end
m = magic(n);
========================================

>> magicsquare1(5)

ans =

    17 24 1 8 15
    23 5 7 14 16
     4 6 13 20 22
    10 12 19 21 3
    11 18 25 2 9

>> mcc -mv magicsquare1.m
(of course MRC is properly installed and configured)

Then the standalone application "magicsquare1" does not produce any output in command-line console!!! But it should, according to the help page of MATLAB compiler.

When I change the function like this:
========================================
function m = magicsquare2(n)
%MAGICSQUARE generates a magic square matrix of the size
% specified by the input parameter n.

% Copyright 2003-2012 The MathWorks, Inc.

if ischar(n)
    n=str2num(n);
end
m = magic(n);
disp(m);
========================================
and recompile by
>>mcc -mv magicsquare.m

I am able to get correct output.
>> !magicsquare2 5
    17 24 1 8 15
    23 5 7 14 16
     4 6 13 20 22
    10 12 19 21 3
    11 18 25 2 9

So my question is: what is wrong? Why I am not able to get output from standalone application magicsquare1?

Thank in advance, Michal

Subject: no standalone apps output in console

From: dpb

Date: 1 Feb, 2013 18:26:45

Message: 2 of 6

On 2/1/2013 11:36 AM, Michal Kvasnicka wrote:
> I have function:
> ========================================
> function m = magicsquare1(n)
...
> m = magic(n);
> ========================================
>
>>> magicsquare1(5)
>
> ans =
>
> 17 24 1 8 15
...
>
>>> mcc -mv magicsquare1.m
> (of course MRC is properly installed and configured)
>
> Then the standalone application "magicsquare1" does not produce any
> output in command-line console!!! But it should, according to the help
> page of MATLAB compiler.

Link???? Don't have the compiler here so didn't try to confirm this...

> When I change the function like this:
> ========================================
> function m = magicsquare2(n)
...
> m = magic(n);
> disp(m);
> ========================================
> and recompile ...
> I am able to get correct output.
...
> So my question is: what is wrong? Why I am not able to get output from
> standalone application magicsquare1?
...

I'd guess nothing is wrong but probably your interpretation of the
documentation...

In the first case you see results at the command line inside ML because
the command interpreter snags the return variable in the hidden default
return target 'ans' and displays it.

OTOH, when you compile it, there's nothing in the code that indicates
anything to the compiler that the output should be displayed since you
included the ';' on the subject line that defines the return variable so
I'm not surprised the compiler didn't generate output display code
internally automagically.

What happens if you use

  m = magic(n) % NB: no ";"

instead out of curiosity?

Also as noted, would be interested in the actual documentation reference
to see precise wording...

--

Subject: no standalone apps output in console

From: Michal Kvasnicka

Date: 1 Feb, 2013 18:43:08

Message: 3 of 6


> What happens if you use
>
> m = magic(n) % NB: no ";"
>
> instead out of curiosity?

Works like charm ... :-)
>magicsquare 5

m =

    17 24 1 8 15
    23 5 7 14 16
     4 6 13 20 22
    10 12 19 21 3
    11 18 25 2 9

Subject: no standalone apps output in console

From: Michal Kvasnicka

Date: 1 Feb, 2013 18:48:08

Message: 4 of 6

> Also as noted, would be interested in the actual documentation reference
> to see precise wording...

see http://www.mathworks.com/help/pdf_doc/compiler/compiler.pdf

page 1-13 and 1-22

Subject: no standalone apps output in console

From: dpb

Date: 1 Feb, 2013 18:49:11

Message: 5 of 6

On 2/1/2013 12:43 PM, Michal Kvasnicka wrote:
>
>> What happens if you use
>>
>> m = magic(n) % NB: no ";"
>>
>> instead out of curiosity?
>
> Works like charm ... :-)
...

Figured as much. That's pretty-much the way it (compiled code) has to
behave--otherwise you'd fill the console w/ output from every line of
code that was an assignment in the entire app...

--

Subject: no standalone apps output in console

From: dpb

Date: 1 Feb, 2013 20:44:08

Message: 6 of 6

On 2/1/2013 12:48 PM, Michal Kvasnicka wrote:
>> Also as noted, would be interested in the actual documentation
>> reference to see precise wording...
>
> see http://www.mathworks.com/help/pdf_doc/compiler/compiler.pdf
>
> page 1-13 and 1-22

Note the NOTE at the top of p 1-19.

I don't see where the doc actual addresses specifically the question of
what does/doesn't generate output other than by the example and that
note. (Then again, I didn't read it all line by line but I did look at
the TOC to try to find a section that seemed like would address such but
the only ones that looked at all promising in Chap 3 didn't have the
specific question addressed.

I think the deal would still be as noted before that if all output went
to the screen even w/ the ';' in place it wouldn't be a useful
implementation.

But, not having the product can't really comment definitively.

Mayhaps one of the TMW folks or somebody else w/ the compiler can
address it in further depth if needed.

--

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