Alternative to the symbolic toolbox

15 vues (au cours des 30 derniers jours)
Dominika
Dominika le 17 Avr 2014
Hi,
I created GUI which at some point contains 'sym' function. Then I tried do make .exe file using Matlab Compiler. As far as I found out Matlab Compiler doesn't support Symbolic Toolbox. Now my question is: how can I deal with the problem?
I need to find fb_ value for which both formulas are equal, all other values are variables specified before. Does anyone have an idea of alternative way of solving the problem without using symbolic toolbox?
part of my code:
% Determine cut-off frequency fb
fb_=sym('fb_')
% sym fb_
fb_syn=solve(20*log10(m1+m2)+20*log10(fb_)-47.3+deltaTL==20*log10(m1*fb_)....
-48 + 20*log10(m2*fb_)-48+20*log10(fb_*d)-29,fb_); % ref.(4), p.397
fb = double(fb_syn);
Thanks for any ideas!
Dominika

Réponses (1)

Walter Roberson
Walter Roberson le 17 Avr 2014
Solve the form ahead of time.
It is easier to solve general forms when one uses rational values instead of floating point such as -47.3 . But if you substitute 473/100 and solve then the reasons for various constants that show up in the solution become obscured. So for the moment substitute a variable, V, for the -47.3, declare all the names involved as syms, and solve. simplify() and expand() and simplify() again. What you can get out will look like,
fb_ = 1000*10^(-(1/40) * V + (1/40) * deltaTL + 1/8) * (m1+m2)^(1/2) / (m2^(1/2) * d^(1/2) * m1^(1/2))
Once you have that formula you can put it into the source code, eliminating the solve() call.
  2 commentaires
Dominika
Dominika le 18 Avr 2014
Thanks for the answer, but I'm not really following... Could you me more precise? I checked on the web and 'simplify' does not run in Matlab, only in the MuPAD Notebook Interface.
Walter Roberson
Walter Roberson le 18 Avr 2014
Modifié(e) : Walter Roberson le 18 Avr 2014
Which MATLAB version do you have? simplify() is defined through MATLAB; see http://www.mathworks.com/help/symbolic/simplify.html
syms fb_ V deltaTL m1 m2 d
FB = simplify(expand(simplify(solve(fb_ = 1000*10^(-(1/40) * V + (1/40) * deltaTL + 1/8) * (m1+m2)^(1/2) / (m2^(1/2) * d^(1/2) * m1^(1/2)), fb_))));
You can even proceed from there to use matlabFunction() to generate .m code into a file that you could then invoke from your executable.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by