# File Exchange Pick of the Week

## Advanced MATLAB: Compiling a GUI

This video shows how to use DEPLOYTOOL to create a project and compile it so that it can be used outside of MATLAB, meaning you can give it to someone that does not own MATLAB and they can still run it.

This is useful in a variety of situations, for example you might want to lock down a functioning GUI so that even as you upgrade MATLAB you will know that your GUI will not change, because it is a stand alone. You might want to obscure your algorithms from people you give your code to.

The demonstration is using an add on product called: MATLAB compiler

http://www.mathworks.com/products/compiler/

Video Content

Find the files here.

PodCast here

Other videos have been gathered here:
http://blogs.mathworks.com/pick/category/video/

Other Advanced MATLAB posts have been gathered here:
http://blogs.mathworks.com/pick/category/advanced-matlab/

### 95 Responses to “Advanced MATLAB: Compiling a GUI”

1. Quan Quach replied on :

Very useful guide. But when I went to the deployment tool, “windows Standalone application” was not one of the options. Also, when I tried to run the deployment tool on a GUI i created, it asked which compiler I wanted to use. Is there a specific one that needs to be used? Also, how do you generate and send out the MCR file that you discussed? Thanks!

2. Dave Forstot replied on :

The MATLAB Compiler deployment target “Windows Standalone Application” was new with MATLAB R2007b. Older versions only had the “Standalone Application” option – the difference being the new Windows Standalone Application does not start a command console (dos box).

The first time you use MATLAB Compiler, it needs to be configured to use a compiler. There is a list of supported compilers on The MathWorks website (TechNote 1601):
http://www.mathworks.com/support/tech-notes/1600/1601.html

You can include the MATLAB Component Runtime (MCR) with your MATLAB Compiler generated executable by using the packaging feature of deploytool. By default the MCR is not included with the executable because of its size. However, if you go into the deploytool settings, under packaging, you can optionally choose to include it. This tab will also show you where the MCR is located on your file system if you want to distribute it separately.

Good luck!

3. Jim Strickland replied on :

Thanks very much for this tutorial. I have R2006a – could you show how I can compile a GUI using this version?

4. Doug replied on :

Jim,

R2006a did not have the deploytool. If you contact support

they can give you details on how to do this. You might even be able to upgrade to the newest version of MATLAB, depending on what you company has purchased.

Doug

5. liantaodu replied on :

I have R2007a ,and I want make some wavelet function to COM,and use the COM in Visual Basic,but I have tried many times,all lost.Could you give me some suggestion?Thanks.

6. Doug replied on :

Lian,

I would need more details to help. I think you are better off going to support directly:

http://www.mathworks.com/support

Cheers,
Doug

7. liantaodu replied on :

function xiaobo
n=[1:50];
x=sin(pi/10*n+pi/3)+2*cos(pi/7*n);
w=randn(1,length(n));
y=x+w;
subplot(3,1,1);
plot(x);
subplot(3,1,2);
plot(y);
xd=wden(y,’minimaxi’,'s’,'one’,5,’db3′);
subplot(3,1,3);
plot(xd);
title(‘ok’);
grid;
This function work well in matlab.
I try to use mcc -vm xiaobo.m to gain a application, but throw
following errors
size of your application. Please wait…
…CTF archive extraction complete.
??? Index exceeds matrix dimensions.

Error in ==> wtbxmngr at 75

Error in ==> dwtmode at 158

Error in ==> dwt at 54

Error in ==> wavedec at 43

Error in ==> wden at 62

Error in ==> xiaobo at 10

MATLAB:badsubscript
Warning: 1 visible figure(s) exist at MCR termination.

did the mcc compiler support wavelet function well?
did the matlab builder for .net support wavelet function well?
please help me? thanks

8. Marco Trincavelli replied on :

Got exactly the same problem!

I cannot really figure out what is that about…

Any help would be highly appreciated!

Thanks

Marco

9. Dave Forstot replied on :

liantaodu and Marco Trincavelli,

I was unable to reproduce this error in MATLAB R2007b on windows.

I copied your code exactly from above, and used the same compiler command. The resulting application behaved the same as the MATLAB function.

Perhaps this was an issue that already been addressed by the developers?

Dave

10. Omar replied on :

I am trying to just run the magicsquare.m file to creat stand alone execytable. But when I try to run the exe file it says ” This application has failed to start because mclmcrrt77.dll was not found. Re-installing the application may fix this problem”.

Can you please suggest the possible reason. I am remotely using the matlab from a server.

Thanks.
Omar

11. Doug replied on :

Omar,

Please contact support:

http://www.mathworks.com/support

Doug

12. Tapon replied on :

very nice show!
But i am not being able to access the deployment tool.
I’ve written deploytool and pressed enter. But it replays me undefined function…
So, what to do… i must be greatful to you…

13. Tapon replied on :

I have seen this video more than 20 times but not getting the answer how to access the deploytool?
Please help me!
My Matlab version is 7.1
Is it a problem for not finding Deploument Tool?
please answer me as soon as possible… i am in a big trouble!

14. Doug replied on :

Tapon,

This is an additional product:

http://www.mathworks.com/products/compiler/

You need to purchase the MATLAB Compiler for this function.

Doug

15. Jiro replied on :

Tapon,

Also, if you do have MATLAB Compiler, “deploytool” was added to the product in R2006b. If you have an older version of the MATLAB Compiler, you need to use the command line functionality (mcc).

jiro

16. Tapon replied on :

Thanks! for reply…
It will be my pleasure if you give me the answer of following…
I made a GUI and saved the m.file in the work directory. thus wrote the command [mcc -mv filename.m] in the command window.
It generates a filename.exe file. this file is executabe.
But it doesnot run in a machine where matlab has not setup. Now i want to make an application that will run in any in any machine independent of Matlab…
is it possible?

17. Jiro replied on :

Tapon,

Which version of MATLAB are you using? Does the .exe file run successfully on the same computer?

You have to install the MCR on machines that do not have MATLAB. Take a look at the documentation for MATLAB Compiler (there might be a section called “Deployment Process”)

If you are having more problems, I suggest you contact support:

http://www.mathworks.com/support

jiro

18. Tapon replied on :

Thanks a lot…
I have solved my problem by the significant help of all of you

19. Julio replied on :

Dear Doug,

Your video is excellent. I’m using Matlab R2008a and have a problem. I used the deploytool and compiled a program I’m coding for Line Codes. It uses 2 .fig GUIs and 4 .m files (2 for figures and 2 as support for the figures). The 2 GUIs are the splash screen (with my name on it) and the main screen. So on the deploytool I put, as main function, the splash.m file. Then I compiled.

The program runs great in MATLAB, but the exe file seems to open and close really fast (not showing anything). If I compile using mcc -e, the program works but I cannot run it in other non MATLAB computers. I also saw that MCR Installer is at “C:\MATLAB\toolbox\compiler\deploy\win32\” Can I take that installer to other computers, run it and then run my program compiled using mcc -e? Or do I need to package it using deploytool? Why is my program not working with deploytool?

Thanks a lot! Keep up the great work!

20. Mukund Agarwal replied on :

I have got exactly the same issue as Julio. Please help!
I even tried waitforcallbacks(true) in the GUIopening function but still

Can you please tell which compiler you use?

Thanks

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.

Warning: Class
‘uitools.uimodemanager’
in use at MCR termination.

If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.

Warning: Class
‘uitools.uimode’
in use at MCR termination.

If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.

Warning: Class
‘graphics.datacursormanager’
in use at MCR termination.

If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.

Warning: Objects of uitools.uibuttongroup class exist – not clearing this class
or any of its super-classes
Warning: Objects of uitools.uimodemanager class exist – not clearing this class
or any of its super-classes
Warning: Objects of uitools.uimode class exist – not clearing this class
or any of its super-classes
Warning: Objects of graphics.datacursormanager class exist – not clearing this
class
or any of its super-classes
MATLAB:imread:fileOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

21. Julio replied on :

I’d like to add something to my comment. I’ve noticed that doubleclicking on the .exe file doesn’t extract the ctf file as you show in your video. Is something wrong with what I’m doing? Maybe an option was left behind where I should’ve clicked.

Thanks!

22. Jiro replied on :

Julio,

In R2008a, the extracted CTF files can be found at

USERPROFILE\Local Settings\Application Data\MathWorks\mcr_cache_v##\


where USERPROFILE is your Windows user profile directory.

I would suggest creating a regular Standalone Application (not Windows Standalone). Then open up a DOS prompt, and run the executable from there. You should see any error messages that may pop up in the process.

23. Julio replied on :

Jiro,

Thank you very much. I debugged using the technique you told me. I found out that my png pictures weren’t found by the program because I didn’t include them in the “other files” section in deploytool (since I followed Doug’s video, but he didn’t use any images).

So, I think this will help Mukund, if you ever have files other than .m or .fig, include them in the Other Files section or the program will not work.

I have another question though. If there’s a new release of MCR (for instance, in MATLAB 2009a), will my program in 2008a (compiled exe file) work in the new MCR? Or should I save a copy of the old MCR.

Thanks again guys, keep up the great work!

24. Jiro replied on :

Julio,

I just want to mention one thing. If the images that you are loading with your program are something that you always need together with your program, then yes you need to add it as “other files”. This is true for any other files that your application needs to “load”. But if your application is meant for loading an arbitrary image that the user specifies, then you shouldn’t have to include them in the application. In this case, one of the common mistakes is that people use just the file name, instead of the complete path of the file. For example, instead of

filename = uigetfile('*.png'); im = imread(filename);

you should use

[filename, pathname] = uigetfile('*.png'); im = imread(fullfile(pathname, filename));

This will ensure that your function will work regardless of where the image file is on your computer.

Regarding your question about MCR, your application will only run with the same version of MCR used to deploy. So your application compiled in R2008a will not run on R2007b or R2008b MCR. But, multiple versions of MCR can co-exist on a computer, and your application will automatically choose the appropriate MCR. That means that when you create other applications in future releases, those applications can run with the new MCR, while your old application can also run on the same computer using the older MCR.

Hope this helps.

25. Julio replied on :

Thank you very much Jiro. Your comment completely helped me and also gave me a new perspective on user specifying a specific file. My images were my University’s logo and a flow chart in png, so those weren’t to choose. About the MCR, do you recommend to package the MCR on every deployment? or instead of that to have copies of every MCR Installer that is released?

Thanks again!

26. Jiro replied on :

Julio,

I think it really depends on your situation. If you are deploying to only a few computers, it might make sense to install the MCR each new release that you get. If you are distributing to a large number of end users, it might be better to package together the MCR with your deployment. Or you may only want to provide the MCR for the first few applications.

27. Nicolas replied on :

Hi Doug. I’m using MatLab 2008a and trying to compile a GUI with an uitable component. The GUI is running great on MatLab but it doen’t work in the standalone application. Do you know what is happening and how to fix it?

Thanks in advance.

28. Scott Hirsch replied on :

This is a known limitation. See the discussion here, with a workaround suggested by one user:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/166196#431145

We hope to have this fixed in R2008B.

29. mak replied on :

hi all,

i have the application which will take the commands from the GUI and read the data available from files. The m file then process the data. So overall i have the application with m files, fig files, text or excel file, and logos stored at different directories.
i want to bulid the .exe. i am giving initial script as the main file and all other files(logos, m and fig files) under other files. it is creating the .exe but after running it, the GUI is quitting (irrespective of waitfor command while calling the fig).
i hv the set of script and function m files. is it due to this. or is thr any other reason for the same.
could u please guide me for the problem..

Thanks…

30. hashem replied on :

dear doug,
your video was very excellent and helpful for me. That was perfect answer for my questions. But a problem remains for me. When i run my program a DOS window is opend that is not my favor. Is a way to resolve this problem.

Thank you beforehand,
Hashem Shahsavany,

31. Doug replied on :

Hashem,

Take a look at this documentation:

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/mcc.html

It talks about the ‘-e’ option to suppress the command window. Give it a try.

Doug

32. Moran replied on :

Doug,
Bringing back a previous discussion topic – compiling a GUI which contains table objects. Unfortunately, I switched to R2008a to be able to use the new uitable, which is exactly what fails to compile properly…

I’m aware of the discussion here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/166196#431145

Indeed, including arrayviewfunc.m and workspacefunc.m in the compilation helped in eliminating the errors. However, the issue of a non-numeric table showing blank cells remains unsolved. Is there any news with regards to that?
Is there a reasonable workaround that I can use in the meantime? (switching the object’s parent after each call to ‘drawnow’ works, but since I continuously update a plot in that figure – it causes the table to flicker).

Thanks!
Moran

33. David replied on :

Hi,

I am not able to run the ‘deploytool’ on my Matlab 2007a. ??? Undefined function or variable ‘deploytool’ is the error message received. Pls let me know how I can run this tool.

Thanks.

34. Steve L replied on :

David,

As Doug mentioned back in comment 14, DEPLOYTOOL is part of MATLAB Compiler. You can check if you have MATLAB Compiler installed by calling the VER function and checking for it in the list of products.

35. Joanna replied on :

Hi Moran,

You can go to http://www.mathworks.com -> Support. Login then choose ‘Bug Reports’. The bug report ID is 449936 – ‘Unable to deploy applications that contain uitables’. Downloading the patch file and following workaround instructions… Good luck!

36. Moran replied on :

Hi Joanna,
Thanks for the reply. However, this takes care only of the compilation errors (equivalent to including arrayviewfunc.m and workspacefunc.m in the compilation) and does not solve the problem of non-numeric tables showing blank cells.

Looks like bug report # 456568 ‘Compiled GUIDE GUIs that contain UITables do not show table data at run time’ refers to the problem I’m encountering. No workaround provided yet.

Cheers,
Moran

37. vivek bhaskar replied on :

Hello Doug,
Great article.
I have matlab r14 sp3.
I noticed one thing when I was making a standalone application of my GUI. My GUI had uigetfile and errdlg functions. When I do
mcc -m mygui.m
it makes a mygui.exe (and .ctf) file which works fine with all the uigetfile and errdlg functionality, but, the command window in the background freezes and cannot be moved or minimized.
This is only true when the gui code in the background uses the uigetfile or errdlg functions. While using other functions/commands, the background command window doesn’t freeze and can be minimized.
Any thoughts?
Vivek

38. Lokesh replied on :

Hi Doug,
I have MATLAB 2007b..
I built a Sample GUI Application like you have told in the video using Deploytool.. using WINDOWS STANDALONE APPLICATION..
But still the DOS Box appears in the background.. !!!
Any thoughts on this…

39. Doug replied on :

Lokesh,

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/mcc.html

You want switch ‘-e’ to suppress command window.
Enjoy

40. Scott Corzine replied on :

I am using R2008a and am using the deploytool to create a standalone GUI application. The exe generation part works fine. Where I am having trouble is figuring out a way to get the path of the standalone executable that the user double-clicked. The ctfroot command points to a place in Local Settings\Application Data\…\myApplication which apparently gets generated on the fly when I first run the executable and it recreates all o fthe .m files in that location. This is not the directory I want. The directory I want is the directory in which the user double-clicked the original standalone .exe file. This is because I have a subdirectory in that directory where the user can place files for my program to load. So I need to know where the original .exe file is so I can locate the subdirectory. pwd and matlabroot do not work either. Any ideas?

41. Todd replied on :

Hi Scott,

Drop me a note at Todd(dot)Flanagan(at)mathworks(dot)com. I have a mex file that solves this problem.

Todd

42. Scott Corzine replied on :

It turns out I was able to solve my problem by disabling my startup.m script using the isdeployed flag with an if statement around the entire code block.

I normally use the startup.m file to automatically switch matlab to my current project folder of interest. I didn’t realize that when you deploy a standalone application, the startup.m file gets sucked into the mix, even though it is not in the list of m-files in the deploytool project! Perhaps there is a setting I haven’t found that can disable this “feature”.

So when I ran the standalone executable, it was actually running a copy of my startup.m file before launching! This was changing my default pwd path. Once I set the startup.m to run like

if ~isdeployed
…startup code…
end

then pwd pointed to the correct path where the standalone executable lives.

43. Stavros replied on :

Hey Scott,

I am trying to create an .exe file for my project that I have developed in Matlab, having several GUIs and .m files. However I cannot create an executable file for my main GUI that calls the other GUIs. (I can create executable file for every single GUI).
Can you please help me?

PS.I have read in a webpage that functions that use variable argument lists (varargin), cannot become executable and my main GUI uses varargin. Is it because of that?

Thank you in advance

44. carol replied on :

Hi Doug,
I am creating a graphical interface in Matlab 7.0.1. My interface as images and when I use the mcc compiler it does not compiles the images, I mean it creates the .exe file but when I try to use it it requests the .jpg files to be in the same folder taht the .exe created. Is there an option in this version of the Matlab compiler (as it does not have the deploytool) that allows me to create a stand alone application that does not need to have the images together with it to run?

Thanks in advance,
Carol

45. Doug replied on :

Carol,

If your program reads in the files, you will need to include them since the compiled version will work the same as the MATLAB one.

Doug

46. Stavros replied on :

Hey Doug,

I am trying to create an .exe file for my project that I have developed in Matlab, having several GUIs and .m files. However I cannot create an executable file for my main GUI that calls the other GUIs. (I can create executable file for every single GUI).
Can you please help me?

PS.I have read in a webpage that functions that use variable argument lists (varargin), cannot become executable and my main GUI uses varargin. Is it because of that?

Thank you in advance

47. Henry replied on :

Hi Doug,

I’m building a GUI and I like to know how to get a subscript, or some other mathematical expression for example in a static text. I’d then like to write
set(handles.static_text,’String’,'\sum_{n=0}^{k}\frac{x^{n}’)
to display but this doesn’t work.

Any help would be highly appreciated!
Thanks.
Henry

48. Doug replied on :

Henry,

I think you might like the TEXT function

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/text.html

The first example shows how that is done.

Doug

49. Chris Dales replied on :

Hi!

Apologies for banging the ‘uitable compile-error’ drum once again (see 32, 36 etc above), but does anyone know whether a satisfactory workaround or fix has been produced to overcome the problem of values/text disappearing from a GUI table in its ‘compiled’ form?

I’ve discovered that, although info disappears once the user has clicked onto another table cell of the compiled GUI, the data entered is still comitted to memory for use in subsequent calculations – it just isn’t visible in the table cells. Most frustrating! We too upgraded to R2008 for this purpose – so any help would be gratefully received.

Thanks!

Chris

50. hashem replied on :

Hi Doug,

I built a GUI and write a help for it in “chm” (compiled HTML file) format, and I can’t find a comment in matlab for openig this file. Is here a comment to opning this
file(s)?

Best regard,
Hashem,

51. odessit replied on :

Hello,
I have compiled standalone application with deploytool. It would work fine, but the error is in c:\user\Administrator\AppData\Local\MathWorks\mcr_cache_v78\myprog_…..\toolbox\images\icons\point.png
This icon is missed and everytime the program try to call it, it crashes. Wenn I copy this icon manually to this folder – it works!
My question is how to compile my program together with this necessary icon? I think it must be compiled automatically. Wich previos version of matlab compiler I had no problems.
Thanks very much for help.
Leo

52. Moran replied on :

Hi Chris,
I tried everything I could think of, and have sent several observations about this bug to support, but eventually lost all hope that this bug will be fixed in the immediate future (it has been already 2.5 months since I encountered it).

Fortunately, a great alternative exists! Check out Yair Altman’s “CreateTable.m” code:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14225&objectType=file

The examples that Yair supplies make it very easy to learn how to use it, even for someone with no previous experience with Java (like me…). Furthermore, this works great (and compiles) on previous versions of Matlab, so no need to upgrade to R2008x, and you can enjoy the much smaller MCR file size (150MB in 2007a vs. 240MB in 2008a).

Hope this helps,
Moran

53. Helen Czerski replied on :

Hi,

I’ve got a problem when compiling a GUI that no-one else has mentioned here. I’m using mac OS 10.5 and I’ve got around all the problems with specifying the library path so I can run non-GUI *.m code. However, a compiled GUI won’t let me change the values in the EditText boxes. The cursor is blinking in the EditText box, but when I type a number it just appears in the Terminal. I’ve tried making the figure modal, but that didn’t help. Is there something obvious that I’m doing wrong?

54. Doug replied on :

Helen,

That question is best asked of tech support. support@mathworks.com

-Doug

55. Patrik replied on :

Hi! Thanks for a great tutorial! Unfortunately I ran into some problems when I followed your tutorial, the DOS-box still appears although I chose Windows stand-alone application. I saw you mentioned the -e flag in an earlier post, but how do I do that? According to the matlab help -F (for projects) cannot be used with any other flag. How come I need to specify this when all other tutorials do not mention this? Thanks again!

//Patrik

56. Doug replied on :

Patrik,

When you generate the .prj file, you can specify the compiler directives, including the -e flag. Once you do that, they will be included in the .prj.

-Doug

57. lindo replied on :

plz give me a solution for my problem

my problem is

i want to change the icon of the matlab standalone excecutable file.

58. Doug replied on :

Lindo,

Sorry, this is not supported.

Doug

59. Lori replied on :

I’m trying to compile using DEPLOYTOOL in 2007a (I *do* have access to more recent versions of Matlab, but not immediately at hand) a more substantial GUI with menus that invoke Callback functions. Unfortunately, the variables being passed into these functions no longer exist when the Callbacks are invoked.. I get errors indicating that the variable is not found. Are there any resources you can point me towards to help me make this work?

Thanks!

60. Richard replied on :

Hello Doug,

Can you explain point 56. (about the -e flag) because I can’t seem to find it.

Regards, Richard

61. Doug replied on :

Richard:

Find it here:

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/mcc.html

Doug

62. Richard replied on :

Thank you for your reply. I understand that I can specify flags using the mcc command, but is this also possible through the deploytool?

Richard

63. Richard replied on :

To whom it may concern, a solution to the dos screen annoyance is found by user ‘vihang’ in this discussion:

http://groups.google.com/group/comp.soft-sys.matlab/browse_thread/thread/0527d566c3b72873

In my case, simply adding “set LINKFLAGS=%LINKFLAGS% -subsystem windows” to compopts.bat does the trick!

Richard

64. Doug replied on :

Richard,

Use the compiler options file, it is found at the bottom of the dialog that you get when clicking on the “Open project settings window” button on the Deploy Tool.

Doug

65. Richard replied on :

Hello Doug, yet another question. I followed this tutorial:

http://blinkdagger.com/matlab/matlab-gui-tutorial-close-gui-confirmation

and it works perfectly in Matlab. However after compiling the gui to a executable, I do get the the question dialog but clicking ‘Yes’ doesn’t close the exe.

Any help is appreciated. Regards, Richard

66. Valerio replied on :

I try to compile this code:


function seat
clc
clear all
close all

stringa= 'dati_Valerio/prova_6/';

ac2 =fopen(strcat(num2str(stringa),'acc2.txt'),'r');
a2 = fscanf(ac2, '%*s %f %*s %f %*s %f %*s %f',[4 inf]);
a2=a2';
fclose(ac2);

ac3 =fopen(strcat(num2str(stringa),'acc3.txt'),'r');
a3 = fscanf(ac3, '%*s %f %*s %f %*s %f %*s %f',[4 inf]);
a3=a3';
fclose(ac3);

for i=1:length(a2)
time(i)=a2(i,1);
acc2(i)=a2(i,4);
acc3(i)=a3(i,4);
end

Nfig = 1;

% INIZIO WAVELET ANALYSIS dei segnali
%
offsetacc2 = -10;
signal = offsetacc2 + acc2;
signalname = 'Accelerazione Testa';
lev   = 8;
nbcol = 128;
topa = 128;  %topa <= nbcol
colorn = 256;
wname = 'db8';
Tsample = time(4)-time(3);

waveletanalysis_dan1(signal,lev,nbcol,topa,colorn,wname,Tsample,Nfig,signalname)

offsetacc3 = -10;
signal = offsetacc3 + acc3;
signalname = 'Accelerazione Sedile';
Nfig = Nfig + 1;

waveletanalysis_dan1(signal,lev,nbcol,topa,colorn,wname,Tsample,Nfig,signalname)

With the waveletanalysis_dan1.m is:

function waveletanalysis_dan1(signal,lev,nbcol,topa,colorn,wname,Tsample,Nfig,signalname)

%Perform the discrete wavelet transform (DWT) at level 5 using db1.
[c,l] = wavedec(signal,lev,wname);
%Expand discrete wavelet coefficients for plot.
len = length(signal);
cfd = zeros(lev,len);
for k = 1:lev
d = detcoef(c,l,k);
d = d(:)';
d = d(ones(1,2^k),:);
cfd(k,:) = wkeep1(d(:)',len);
end
cfd =  cfd(:);
I = find(abs(cfd)<sqrt(eps));
cfd(I) = zeros(size(I));
cfd    = reshape(cfd,lev,len);
cfd = wcodemat(cfd,nbcol,'row');

figure(Nfig)

%Perform the continuous wavelet transform (CWT) and visualize results
set(subplot(3,1,1),'Xtick',[]);
plot(signal,'r');
title(strcat('{\bf',signalname,'}'));
set(gca,'Xlim',[1 length(signal)]);
subplot(3,1,2);
colormap(cool(colorn));
image(cfd);
tics = 1:lev;
labs = int2str(tics');
set(gca,...
'YTicklabelMode','manual','Ydir','normal', ...
'Box','On','Ytick',tics,'YTickLabel',labs ...
);
title('Discrete Transform, absolute coefficients.');
ylabel('Level');
set(subplot(3,1,2),'Xtick',[]);
subplot(3,1,3);
scales = (1:topa);
cwt(signal,scales,wname,'plot');
colormap(cool(colorn));
tt = get(gca,'Yticklabel');
[r,c] = size(tt);
yl = char(topa*ones(r,c));
for k = 1:1:r , yl(k,:) = tt(k,:); end
set(gca,'Yticklabel',yl);

The problem is in wavelet analysis. Thanks

67. OneM replied on :

Hi Doug,
***********************
Doug replied on June 25th, 2009 at 14:27 UTC :
Richard,

Use the compiler options file, it is found at the bottom of the dialog that you get when clicking on the “Open project settings window” button on the Deploy Tool.
***********************
I follow this exactly but it does not work. The DOS window still appears. Please advise. Thanks.

68. Hamad replied on :

i try to compile a m-file with mcc -mv file name , but i get this Error
Der Befehl “cmd” ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Error: An error occurred while shelling out to mbuild (error code = 1).
Unable to build executable.
??? Error using ==> mcc
Error executing mcc, return status = 1 (0×1).

pleas any one can me help

69. Doug replied on :

@Hamad,

Please contact your local technical support.

http://www.mathworks.com/support

Doug

70. jigar patel replied on :

i have made one gui based m-file for audio & video recording & playing in matlab….

ma gui based m file is working properly but when i make
.exe using mcc command….i get warning

Warning: No matching builtin function available for C:\MATLAB7\toolbox\simulink\simulink\set_param.bi

but it become .exe
when i run dat .exe
my audio section work properly but when i try to record video my system crash….
without any error mentioning….

plz help me….

71. Doug replied on :

@Jigar

Please see

http://www.mathworks.com/support

Doug

72. Gazilion replied on :

Hi! I have version 2008a and everything works, except in one thing: contrary to what someone said on an earlier comment, whether I create a “standalone application” or a “windows standalone application”, when I run the .exe file it always opens a dos prompt window before opening the actual application window. Any idea why?

73. Doug replied on :

@Gazilion,

Try the -e option:

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/mcc.html

Doug

74. andres replied on :

how can i do if i dont want use MCR…. i have visual studio 2008, and i dont want buy matlab compiler, so how can i compile my file with visual studio.

thanks!

75. Doug replied on :

@andres,

This is the only supported method.

Doug

76. Ashish replied on :

Hello,
I’m trying to build a standalone application with many GUIs n .m files. Along with that console problem, I’m getting another error about a pre-compiled net(Neural Network). I hv included Neural Network toolbox in project settings of Deploytool. The error is about sim command. Application is not recognizing the net variable in sim command. net_5.mat contains the pre-compiled neural network. ControlData contains testing inputs for neural net net_5.
This program runs perfect with Matlab. It gives error only in standalone application. Plz help me out. Error is about class of net_5.


load net_5;
ControlData =[ani_vect;C_compactness;MinODVect;NCVect;BFDVect;ND_vect];
result = sim(net,ControlData);

77. Doug replied on :

@Ashish

Please see http://www.mathworks.com/support

Doug

78. Wendy replied on :

The files (and GUI) that I’d like to compile include the use of a special SDK from another company’s product that we’re interfacing with (for which we have the libraries/necessary files) for collecting streaming data. Is it even possible to compile something with an SDK or are there only special cases when it could work? We’ve included all the library files that are in the folder we normally run the program from, but we still get an error-
??? Error using ==> loadlibrary at 474
There was an error loading the library

This is why we’re wondering if it’s not even possible to compile an m file that needs to load an SDK library file. Thanks for any advice you can offer.

79. Doug replied on :

Wendy,

I am not an expert in this area. However, I know you can include other files in the bundle when you compile. I would call tech support for specifics, but I think this should be possible.

Doug

80. Lindsay Graves replied on :

I have a matlab project that uses mex32 files and wanted to know how to get these files linked as part of the exe. Simply adding the .c files in the project folder c\c++ does not work.
I have switched between mexopts and the default options file.
I was getting an error during the link that it was impossible to open
c:\PROGRA1\MATLAB\r2008B\extern\lib\win32\lcc\.def

I have a mexfunction.def in that directory but notion other than
EXPORTS
mexFunction

in the file. I’m not sure why I am unable to create an executable.

81. Tannistha replied on :

I am trying to compile a GUI which is like a main function that calls on other GUIs as well, also it includes pictures from a subfolder in the same folder where the main file is situated and a files from a library folder also in the main folder. The pictures have all been referenced using the relative path. I am trying to compile it using the compiler version: 4.12 (R2009bSP1) and have a no of errors.

I have tried both the command line function as well as the deployment tool, but something is going wrong in the process.
The command line code I use is
mcc -e ReportGenTest -a ./Symbol -a ./Mylib
% both of them are subfolders in the folder where my m file is located

I understand now matlab compiler can compile files using relative path and all I need to do is to append them from command line or use add files/directories using the deploytool. Sadly I am having the following problems:
The ms dos consol still comes up

If I copy and paste this .exe and .prj file to some other folder in my network it doesn’t work at all, however I need this windows standalone application to run on a computer that has MCR but no MATLAB.
The .exe file created using deploytool doesn’t work at all.
I read the images as follows
imagearray = imread(‘.\Symbol\image.bmp’);

I ran the .exe file using command window and its closing because there r some invisible images, or the images do not exist. My guess is, it is not compiling the subfolder that contains the images.
I am not sure where I am going wrong and any pointers would help

82. suresh dahiya replied on :

Hi,
I am able to convert my .m file GUI program into .exe file using deploytool. When I start it first command window opens then GUI widow opens, But I want to suppress command window during execution of exe program as well I want to reduce starting time time of program. Please provide good sugestion if you have….
Thanks and regards

83. Teresita replied on :

I have a problem. When compiling the program using the Phidget library, I can not find a brand that variable or function phidget21_proto.
I think it’s a problem with the library, and will not let me compile. I did an example with another program from a graph and that if I make the executable.

this is the error which shows me

MATLAB: UndefinedFunction
Warning: 1 invisible figure(s) exist at MCR termination. Advertencia: una figura invisible (s) existen en la terminación de MCR.

If your application has terminated unexpectedly, please note that Si la aplicación ha terminado de forma inesperada, por favor, tenga en cuenta que
applications generated by the MATLAB Compiler terminate when there are no aplicaciones generadas por el compilador de MATLAB terminan cuando no hay
visible figure windows. ventanas visibles figura. See the documentation for WaitForFiguresToDie and Consulte la documentación de WaitForFiguresToDie y
WAITFORCALLBACKS for more information. WAITFORCALLBACKS para más información.

Warning: Class Advertencia: Clase
‘uitools.uimodemanager’ ‘Uitools.uimodemanager’
in use at MCR termination. en uso en la terminación de MCR.

If your application has terminated unexpectedly, please note that Si la aplicación ha terminado de forma inesperada, por favor, tenga en cuenta que
applications generated by the MATLAB Compiler terminate when there are no aplicaciones generadas por el compilador de MATLAB terminan cuando no hay
visible figure windows. ventanas visibles figura. See the documentation for WaitForFiguresToDie and Consulte la documentación de WaitForFiguresToDie y
WAITFORCALLBACKS for more information. WAITFORCALLBACKS para más información.

Warning: Class Advertencia: Clase
‘uitools.uimode’ ‘Uitools.uimode’
in use at MCR termination. en uso en la terminación de MCR.

If your application has terminated unexpectedly, please note that Si la aplicación ha terminado de forma inesperada, por favor, tenga en cuenta que
applications generated by the MATLAB Compiler terminate when there are no aplicaciones generadas por el compilador de MATLAB terminan cuando no hay
visible figure windows. ventanas visibles figura. See the documentation for WaitForFiguresToDie and Consulte la documentación de WaitForFiguresToDie y
WAITFORCALLBACKS for more information. WAITFORCALLBACKS para más información.

Warning: Class Advertencia: Clase
‘graphics.datacursormanager’ ‘Graphics.datacursormanager’
in use at MCR termination. en uso en la terminación de MCR.

If your application has terminated unexpectedly, please note that Si la aplicación ha terminado de forma inesperada, por favor, tenga en cuenta que
applications generated by the MATLAB Compiler terminate when there are no aplicaciones generadas por el compilador de MATLAB terminan cuando no hay
visible figure windows. ventanas visibles figura. See the documentation for WaitForFiguresToDie and Consulte la documentación de WaitForFiguresToDie y
WAITFORCALLBACKS for more information. WAITFORCALLBACKS para más información.

I could help with this error?

84. Vaibhava replied on :

Hey! I have three .fig files and m files associated with them. Is there any method using deploytool to make one .exe file from them? I want just one .exe file to be executed which will ask user which of the three .fig files he wants to run, and when he selects one of the three, .fig file and the m code associated with it is executed. Could you please suggest me how to do this?

85. AJ replied on :

Hi there,
I have created a Matlab script, using Matlab’s ‘guide’ program. Is this supported in the Matlab Compiler? Also, my script involves loading jpgs into the gui. It runs fine on Matlab. Is it possible to have jpgs load in the executable compiler? Figured I’d ask before going through all the steps to hopefully save some time..

Sincere thanks.

86. Anthony replied on :

Hi,

I have code which creates a data_structure.m file (which basically lists header names and corresponding column placement) based upon a input txt file. Once the data_structure.m is created, I then load the actual data into data_mat and with data_strucutre(data_mat) I’m able to create a data.fields struct whereby fields are represented by the header names

    data_mat=load([char(new_name(k)) '.ascii']);
pause(2);
%
% Read in Data Structure
data = data_structure(data_mat);


Now, when I create a window exe file of my code, I receive the following error;

??? Undefined function or method 'data_structure' for input arguments of type 'double'.
`

How do I call another .m function (data_structure) from within a compiled window exe file?

Thanks in advance.

87. Kyaw replied on :

Dear All,

I am stuck deploying with the error message below while using Matlab 2008a and Microsoft Visual Studio 2005 SP2.
‘cmd’ is not recognized as an internal or external command,
operable program or batch file.
Error: An error occurred while shelling out to mbuild (error code = 1).
Unable to build executable.
??? Error using ==> mcc
Error executing mcc, return status = 1.

There were errors during compilation process

However, there was no issue using Matlab 2010a and Microsoft Visual Studio 2005 and pls advise me.

Thanks and best regards
Kyaw

88. Walid Al-Gherwi replied on :

Hi Jiro,

I started using the MATLAB compiler recently but I am having a problem when I build the .exe files that it takes way too long to complete this task and I have same issue when I have to add the MCR using the package step. I tried to reduce the number of toolboxes in the path settings but it still takes the same time. I would really appreciate your help in this regards.

Thanks

89. Syed Ali replied on :

1. Can we compile Matlab code using 2009b on XP machine and run the same code on Win-7 machines.

2. Can codes compiled on 32-bit machines run 64-bit machines or we have to compile on 64-bit machine.

3. In order to have good compatibility is it necessary we compile code in the same operating system also.

90. AndyHefei replied on :

Second time today I have to thank you guys for these extremely helpful bits about Matlab!
Again you saved me lots of time!!

91. Ingrid Keupers replied on :

When I compile my GUI on different computers, the executable has quite a different size. On the computer with matlab compiler ver4.16 the .exe file is only 338Kb large. When I compile on my own computer were ver4.17 is installed, the executable is 10,004Kb which is considerably larger (and making it difficult to distribute my mail!). Exactly the same files are being used to compile so where does this large difference come from? Is this a known side effect of the different versions or should I change some kind of settings?

thank you very much for your help

92. Ingrid Keupers replied on :

It was not a problem of different versions, only of the settings on my own computer. I do not know how it happened but my preference directory was huge so this site (http://www.mathworks.nl/support/solutions/en/data/1-1BG1C/index.html) helped me to restore it to the original normal size and the compiled .exe returned to it’s normal size after doing this.

Hope this helps others with the same problem!

93. diana replied on :

We have created a GUI calling another .exe (placed in a subfolder) to do some complex calculation, input and output data are provided in two different subfolders; all are specified as relative path. The compiled GUI starts normally but then it doesn’t work: preparing the package, We have to include the exe subfolder or not? It seems as the compiled GUI doesn’t find that exe..
Thanks in advance

94. Farid replied on :

Dear Doug

I am a beginner with Matlab. So my question might be stupid but please help. When I want to “Build” I get the error
” Run mbuild -setup to specify the default compiler options files”

Why is that?

95. abdol hamid replied on :

Thank you so much,,,, Damet Garm Baba.
You solved my problem,,,, moshkelom kamelan raf shod
Great regards,,, kheili mokhlesim kakam jan

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of MathWorks.