Matlab Compiler Magic Numbers example won't work

I have followed the magic number example in the documentation and for whatever reason it will not run at all. All it does is make the "windows ding" noise indicating something went wrong but doesn't give me an explanation.
Is there any additional steps to this example I should be making that aren't described in the text?

回答 (3 件)

Titus Edelhofer
Titus Edelhofer 2013 年 1 月 30 日

1 投票

Hi Ryan,
a good way to find out: start a windows command window (hit the windows start button, enter "cmd" as command. It should open the black console window.
cd to the folder where your .exe is.
Start the .exe "manually". Errors get displayed then in the cmd window. That should indicate whats wrong (or give you something that you can post so we have a chance to see what went wrong).
Titus

7 件のコメント

Ryan Matheson
Ryan Matheson 2013 年 1 月 30 日
That is a really great idea.
Ryan Matheson
Ryan Matheson 2013 年 1 月 30 日
After running the .exe in the terminal gives me the following:
Error using magicsquares 7 Not enough input arguments.
I understand the nature of this error but find it strange that as an example given in the documentation would fail in this way without any mention of how to account for this. Every example online for the compiler is pretty straight forward with drop your .m file in with any supporting files and hit build. How can I learn from this and figure out how to make this work properly?
Ryan Matheson
Ryan Matheson 2013 年 1 月 30 日
編集済み: Ryan Matheson 2013 年 1 月 30 日
the actual code for the magic squares program is as follows:
function m = magicsquare(n)
%MAGICSQUARE generates a magic square matrix of the size specified
% by the input parameter n.
% Copyright 2003-2006 The MathWorks, Inc.
if ischar(n)
n=str2num(n);
end
m = magic(n)
Image Analyst
Image Analyst 2013 年 1 月 30 日
編集済み: Image Analyst 2013 年 1 月 30 日
The 7 link in your comment doesn't work. Like I already asked, exactly how are you running it? Apparently you're running it from an operating system console window, but are you doing "magicsquare 7" or "magicsquares 7" or "magicsquare(7)" or "magicsquares(7)"? The code is singular: magicsquare, not magicsquares like you gave in the error message, so it has me wondering exactly where and how many times and places you have mismatched names.
Ryan Matheson
Ryan Matheson 2013 年 1 月 31 日
The .m file called magic squares is a pre-made example code that comes with Matlab and can generally be found in
c:/programfiles/Matlab20XXx/extern/compiler/magicsquare.m
This is a direct example from the resources called "Magic Square Example" which you can find in the help navigator. Essentially my problem is I followed the instructions, which were very simple, and can't figure out what I'm missing. The program should be asking for an input but instead just crashes. I would like to get this example running so I can move on to bigger and more complex things.
Ryan Matheson
Ryan Matheson 2013 年 1 月 31 日
Oh wait I see what you mean by the "7" the error read,
Error using magicsquares < 7 >
I am also using your suggestion at this point and did run it in a console.
Titus Edelhofer
Titus Edelhofer 2013 年 2 月 19 日
If you need to pass arguments, you should do so, i.e.,
cd c:\PathToYourExecutable\
magicsquare 5
Where 5 is the parameter n.
Titus

サインインしてコメントする。

Image Analyst
Image Analyst 2013 年 1 月 29 日

0 投票

Exactly how are you trying to run the exe on the target computer?
Noah Frere
Noah Frere 2016 年 8 月 3 日

0 投票

Hello all. I am having a similar problem, but with MATLAB R2016a. I compiled magicsquares and ran it from terminal in Mac 10.11.4 El Capitan. Here's my command:
Noahs-MacBook-Pro:application noahfrere$ ./run_magicsquare.sh /Applications/MATLAB/MATLAB_Runtime/v901
and here's the result:
Setting up environment variables
---
DYLD_LIBRARY_PATH is .:/Applications/MATLAB/MATLAB_Runtime/v901/runtime/maci64:/Applications/MATLAB/MATLAB_Runtime/v901/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v901/sys/os/maci64
Not enough input arguments.
Error in magicsquare (line 7)
MATLAB:minrhs
I did not enter the argument this time since I followed the prescription that worked for a different function:
function hello
disp('hello jill')
end
which worked just fine, using in Terminal:
Noahs-MacBook-Pro:for_redistribution_files_only noahfrere$ ./run_hello.sh /Applications/MATLAB/MATLAB_Runtime/v901
which output:
------------------------------------------
Setting up environment variables
---
DYLD_LIBRARY_PATH is .:/Applications/MATLAB/MATLAB_Runtime/v901/runtime/maci64:/Applications/MATLAB/MATLAB_Runtime/v901/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v901/sys/os/maci64
hello jill
When I tried running magic squares as recommended in the Mathworks tutorial:
Noahs-MacBook-Pro:application noahfrere$ ./magicsquare.app/Contents/MacOS/magicsquare 5
then the result is:
dyld: Library not loaded: @rpath/libmwlaunchermain.dylib
Referenced from: /Applications/magicsquare/application/./magicsquare.app/Contents/MacOS/magicsquare
Reason: image not found
Trace/BPT trap: 5
I tried a little coding following the readme.txt, which says: "If it is defined, set it to the concatenation of these strings:
${LD_LIBRARY_PATH}:
MCR_ROOT/v901/runtime/maci64:
MCR_ROOT/v901/sys/os/maci64:
MCR_ROOT/v901/bin/maci64"
changing the contents of the run_magicsquare.sh file so that it included "v901", which it did not include initially. However, I did not do that for the hello jill function. Either way, I couldn't get the magic squares executable to display the magic square.
Any ideas?
Also, the whole point of this is to eventually make a pretty complicated GUIDE gui executable. -or at least the functions that the gui contains. (that is, it doesn't have to be the gui if Matlab doesn't support that kind of activity). Basically, my code takes a bunch of data and takes the fft(data), the stft(data), graphs it, finds total energy, and finds percent error between the un-interpolated and the interpolated computations, and the frequencies at which the maximum values of the energy spectrum occur, for different sets of data. The idea is that when we get new data, we can analyze all of it with a single click on anyone's computer, rather than import it into Matlab, since not everyone will be using Matlab presumably.
Thanks for any help!
Noah

1 件のコメント

Jintao Chen
Jintao Chen 2016 年 11 月 17 日
編集済み: Jintao Chen 2016 年 11 月 17 日
Hi Noah,
Hope you have solved your problem already. First thing first, there is no need to modify the output sh program.
For the issue of:
Not enough input arguments.
My answer may sound stupid, but you may want to check to see if you added below code at the beginning of your code out of practice, which I did.
clc; clear;
It removes the argument I just input. Remove it if you have it.
For the issue of
Reason: image not found
The command
./magicsquare.app/Contents/MacOS/magicsquare 5
you used doesn't make sense for me because - you first miss the space between used app and reference file - you are referring to only the library related with magicsquare but not other essential library for the standalone executable to run
Try this command instead and it may solve your issue
./run_magicsquare.sh /Applications/MATLAB/MATLAB_Runtime/v901 5'
Hope it helps.
Appreciate you sharing your questions here, it helped me to solve my issue.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2013 年 1 月 29 日

編集済み:

2016 年 11 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by