Alternative to the symbolic toolbox
14 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Walter Roberson
2014-4-17
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 个评论
Walter Roberson
2014-4-18
编辑:Walter Roberson
2014-4-18
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!