How to solve transfer function inside summation?

I tried this method:
kr=600;
kp=9;
s=tf('s');
Gc_r= (0.866*s - n*50*pi)/((s^2) + 6*s + (n*100*pi)^2 );
sol= subs(Gc_r, n, 1:2:9);
f=sum(sol)
r_term=f*kr
Gc=kp+r_term
But, it is giving this error : Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To
perform elementwise matrix powers, use '.^'.
I corrected above mentioned error but it didn't work.
error : Undefined operator '.^' for input arguments of type 'tf'.
__________________________________________________________
I also tried this method:
kr=600;
kp=9;
syms s n
Gc_r= (0.866*s - n*50*pi)/((s^2) + 6*s + (n*100*pi)^2 );
sol= subs(Gc_r, n, 1:2:9);
f=sum(sol)
r_term=f*kr
Gc=kp+r_term
It didn't simplified answer either. returned in the form of sum of products.

 Accepted Answer

Symbolic variables do not mix with tf. You cannot use subs() with a tf
You need to use your second approach. Then
[N, D] = numdem(Gc);
collect(N,s) / D
or just
collect(Gc, s)
which will collect the denominator too when the first approach leaves it factored.

4 Comments

If you want to use tf then use a loop or arrayfun to build the total instead of putting in symbolic n, which is incompatible with tf
thankyou @walter ... it worked!
can you please develop code using tf ? it would be helpful for me in my future works.
kr=600;
kp=9;
s=tf('s');
n = 1;
f = (0.866*s - n*50*pi)/((s^2) + 6*s + (n*100*pi).^2 );
for n = 3:2:9
f = f + (0.866*s - n*50*pi)/((s^2) + 6*s + (n*100*pi).^2 );
end
r_term = f*kr;
Gc = kp+r_term;
Gc
Gc = 9 s^10 + 2868 s^9 + 1.443e08 s^8 + 3.731e10 s^7 + 7.432e14 s^6 + 1.467e17 s^5 + 1.408e21 s^4 + 1.895e23 s^3 + 8.176e26 s^2 + 5.702e28 s + 6.099e31 -------------------------------------------------------------------------------------------------------------------------------------------------- s^10 + 30 s^9 + 1.629e07 s^8 + 3.908e08 s^7 + 8.551e13 s^6 + 1.539e15 s^5 + 1.661e20 s^4 + 1.994e21 s^3 + 1.003e26 s^2 + 6.019e26 s + 8.363e30 Continuous-time transfer function.
Though it may not matter for this particular example, you should consider using ss objects instead of tf objects for this type of computation.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!