Clear Filters
Clear Filters

Problem running symbolic toolbox in a loop

2 views (last 30 days)
hi,i am working on a model identification techinque, so i have used symbolic tool box for some mathematics. I am facing issues when i run the mathematics in a for loop. The program is taking too long to execute and sometimes it even hangs up. I would like to know if it is the symbolic tool box is so heavy on the compuation side if i run it in a loop.
  4 Comments
Torsten
Torsten on 1 Sep 2022
Imagine how big the expressions for Ysim become for N=9 - this will make calculating Ysim symbolically extremely slow.
In the code above, I don't see any reason to use the symbolic toolbox. Try to avoid it for N large.
Prithvi Raj Murthy
Prithvi Raj Murthy on 1 Sep 2022
Actually i am using a transfer function model to predict my system from data. so i used symbolic toolbox for the variables to calculate the different parameters of the model. Is there anyother alternate that i can work on

Sign in to comment.

Answers (1)

Vidip Jain
Vidip Jain on 5 Oct 2023
I understand you are using symbolic toolbox for some mathematical computation in a for loop and the program is taking too long to execute.
Yes, the Symbolic Toolbox in MATLAB can be heavy on the computation side, especially when running in a for loop. This is because the Symbolic Toolbox has to perform a lot of symbolic operations, such as differentiation, integration, and simplification.
If you are using the Symbolic Toolbox to calculate the parameters of a transfer function model, then there are a few things you can do to improve the performance of your code:
  • Avoid using the Symbolic Toolbox in a for loop. If possible, try to calculate the parameters of the transfer function model outside of the for loop. For example, you could calculate the parameters in a separate function and then pass them to the for loop.
  • Use the Symbolic Toolbox function ‘simplify()’ to simplify the symbolic expressions. This can help to reduce the size of the symbolic expressions and improve the performance of the Symbolic Toolbox.
  • Use the Symbolic Toolbox function ‘assume()’ to specify the assumptions about the symbolic variables. This can help to improve the performance of the Symbolic Toolbox by reducing the number of symbolic operations that need to be performed.
For further information, refer to the documentation links below:

Categories

Find more on Symbolic Math Toolbox 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!