performance issue of evaluation symbolic expression in Matlab 2014a

1 回表示 (過去 30 日間)
Yonghao
Yonghao 2014 年 7 月 12 日
編集済み: Star Strider 2014 年 7 月 13 日
Hello, Is there any fast way to have evaluate the numeric value in latest version 2014a? For example the following simple test code
tic
syms f phi
f = phi^2 - phi - 1;
v1 = randn(1000,1);
val = double( subs(f,phi,v1) );
toc
In Matlab 2012a you can write the line " val = double( subs(f,phi,v1) ); " as val = subs(f,phi,v1); " directly without "double()" to get the value. But in version 2014a you will get symbolic expression if you do not use double(). However for above same code. The speed of computation is massively slower than the old version, Especially when my symbolic expression is more complicated.
For my PC the above code has the following results:
  • It takes about 0.006 seconds on version 2012a
  • It takes about 0.190 seconds on version 2014a
It's 32 times slower in the newer version!!! My real application cannot executed in the new version due to the speed. Any experts can give me some advices on this?
Many thanks

回答 (1 件)

Star Strider
Star Strider 2014 年 7 月 13 日
編集済み: Star Strider 2014 年 7 月 13 日
On my laptop with R2014a, casting it as a function is about 3¼ times faster than using subs. Using double actually slows it down a bit.
Illustrating:
tic
syms f phi
f(phi) = phi^2 - phi - 1;
v1 = randn(1000,1);
val = double(f(v1));
toc
That should also be an option in R2012a.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by