I am trying to solve an equation like below in Matlab
ai
, bi
, and ci
are vectors of length 10 and these vectors change through the code. this code has to be executed more than 1 million times. So, the method for finding x
must be very fast. I tried the following codes:
method 1:
s=tf('s');
sys=0;
for i=1:10
sys =sys+a(i)/(s*b(i)+c(i));
end
[roots1] = zpkdata(sys,'v');
in this case, the for
loop takes 0.1 second to be completed and [roots] = zpkdata(sys,'v');
executes in less than 0.005 seconds. So, preparing the equation sys
before being solved by zpkdata
takes a long time for a million time run in the real case. Seemingly vectorized operation does not work for 'tf' argument type.
Next, I checked the following method: method 2:
syms x
sys=sum(a./(x*b+c));
[roots1]=vpasolve(sys,x)
this symbolic method was again slow and took 0.13 seconds to get executed.
Do you know any fast method suitable for my case? Or, do you know a way to prepare sys
more quickly in method 1?
Many tnx.