My file compiled .exe does not run as it should.
Show older comments
Good morning. I have the following problem I have 4 file files: form1.fig form1.m form2.fig form2.m I'm trying to make a single compiled .exe file with these 4 files, but I can not get the actions contained within form2.fig and form2.m to run. There are calculated data that must be transferred from the form1.ma form2.my and I am using the function (eval) in form1.m (which according to the documentation could give problems when compiling, however I do not see that is affecting the compilation corresponding to the form1.m) When executing my files inside MATLAb there are no problems in the execution, I do not know why in the compiler if there are problems. If you think it is necessary, I leave the files in the post for analysis. Thank you very much for your help.
6 Comments
Rik
on 21 Jul 2019
I have very little experience with compiling code, but from your description it sounds like you're using GUIDE (which I'm not a fan of) and eval (which is a bad design in (almost) every case).
Since you are compiling your code it makes intuitive sense to me that there may be a difference, especially when using complex runtime functions like eval.
Try to reduce your code to the smallest unit that reproduces the issue. That helps tracking down the cause, and it helps people on this forum to help you more effectively.
Pedro Guevara
on 22 Jul 2019
Pedro Guevara
on 24 Jul 2019
Walter Roberson
on 24 Jul 2019
Which toolboxes are you using? In particular are you using Symbolic toolbox? That cannot be compiled.
If you attach your code and fig here probably someone will look at it, assuming it has some comments. (People tend to give up quickly on long uncommented code)
Pedro Guevara
on 24 Jul 2019
Pedro Guevara
on 24 Jul 2019
Answers (1)
Walter Roberson
on 24 Jul 2019
Absolutely nothing about the Symbolic Toolbox can be compiled.
The work-around (which is not always good enough) is to do the calculations in symbolic form ahead of time and generate matlab code from the result, such as using matlabFunction() with the 'file' option.
matriz_fuerzas_c {1, 2} = ['Fx', num2str( Despl_T2(AA_U,NP+1) ) ] ;
That block of code looks suspicious to me. I suspect you are trying to use numbered variables -- which would fit in with your earlier use of eval() .
maxLength = max (length (num2str (matriz_fuerzas_c {count1,count2})),maxLength);
Sure enough: num2str() applied to a character vector that contains a variable name, is equivalent to eval() of the variable name. You have only gotten rid of the eval() on the surface.
11 Comments
Pedro Guevara
on 24 Jul 2019
Edited: Pedro Guevara
on 24 Jul 2019
Walter Roberson
on 24 Jul 2019
para and si and fin are not valid MATLAB code. tamaño is not a valid MATLAB variable name.
"I create all the numbered variables because I need them to display matrices in an organized way in several msgboxes."
Put the data into a cell array and index the cell array.
Pedro Guevara
on 24 Jul 2019
Walter Roberson
on 24 Jul 2019
matriz_fuerzas_c {1, 2} = ['Fx', num2str( Despl_T2(AA_U,NP+1) ) ] ;
would become something like,
matriz_fuerzas_c {1, 2} = Fx_cell{Despl_T2(AA_U,NP+1) } ;
and lines such as
maxLength = max (length (num2str (matriz_fuerzas_c {count1,count2})),maxLength);
would become
maxLength = max (length (matriz_fuerzas_c{count1,count2}), maxLength);
If at some point you need a name of the Data to be displayed, then you can store the name of the data in a way very much like you are calculating right now, ['Fx', num2str( Despl_T2(AA_U,NP+1) ) ] . The problem is not in building strings that can be understood by users: the problem is that you should not use those strings to access data.
Pedro Guevara
on 24 Jul 2019
Walter Roberson
on 24 Jul 2019
You still will not be able to use anything from the Symbolic Toolbox.
Pedro Guevara
on 24 Jul 2019
Pedro Guevara
on 25 Jul 2019
Walter Roberson
on 26 Jul 2019
Your line
['Fx', num2str( Despl_T2(AA_U,NP+1) )]
implies that you have a series of numbered Fx variables, Fx1, Fx2, and so on. You should store all of those in a cell array
Fx_cell = {Fx1, Fx2, Fx3, ....};
Do not attempt to generate those entries in a loop: if you do not know the number of them ahead of time then you should not be generating the variable names dynamically.
Pedro Guevara
on 26 Jul 2019
Walter Roberson
on 26 Jul 2019
I am not willing to debug the use of dynamic variable names.
Categories
Find more on Matched Filter and Ambiguity Function in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!