Using symbolic subs in for loop

2 views (last 30 days)
ben
ben on 10 Feb 2018
Edited: ben on 10 Feb 2018
Hi,
I have the following equation:
syms tf zeta taum tgo
eq = (exp(-tgo/taum)+tgo/taum-1)^2;
INT = int(eq,tgo);
TauM = 5;
dt = 0.01;
Tgo = 10;
for Tgo > 0
INT = double(subs(INT,{tgo,taum},{Tgo,TauM}));
Tgo = Tgo - dt
end
My question is: using subs inside the for loop slows it down. Is there anyway to make it faster? (The problem is Tgo is dynamic).
P.s. In this example I could write the integral not a syms however in many problems I would like to insert the function and run the code and not to do all the work before.
Thank you.

Answers (0)

Community Treasure Hunt

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

Start Hunting!