# How do you substitute x(1),x(2),x(3) in place of kp,ki and l respectively?

4 views (last 30 days)
Neelanjan Pal on 22 Apr 2020
Edited: VBBV on 5 Sep 2021
y=((1/10^(l + 1)*ki*kp*l*sin((pi*l)/2))/(kp + (ki*kp*cos((pi*l)/2))/10^l) - (1/10^(l + 1)*ki^2*kp^2*l*cos((pi*l)/2)*sin((pi*l)/2))/(10^l*(kp + (ki*kp*cos((l*pi)/2))/10^l)^2))/((1/10^(2*l)*ki^2*kp^2*sin((pi*l)/2)^2)/(kp + (ki*kp*cos((l*pi)/2))/10^l)^2 + 1) - (1/(25*((2^(1/2)*10^(1/2))/5 + 1)^2) - (2^(1/2)*10^(1/2))/(100*((2^(1/2)*10^(1/2))/5 + 1)))/(4/(5*((2^(1/2)*10^(1/2))/5 + 1)^2) + 1)
How do you substitute x(1),x(2),x(3) in place of kp,ki and l respectively so that i can convert it into a function in x: @x y ?

James Tursa on 22 Apr 2020
Edited: James Tursa on 22 Apr 2020
To keep your equation the same, e.g.,
y1 = @(kp,ki,l) ((1/10^(l + 1)*ki*kp*l*sin((pi*l)/2))/(kp + (ki*kp*cos((pi*l)/2))/10^l) - (1/10^(l + 1)*ki^2*kp^2*l*cos((pi*l)/2)*sin((pi*l)/2))/(10^l*(kp + (ki*kp*cos((l*pi)/2))/10^l)^2))/((1/10^(2*l)*ki^2*kp^2*sin((pi*l)/2)^2)/(kp + (ki*kp*cos((l*pi)/2))/10^l)^2 + 1) - (1/(25*((2^(1/2)*10^(1/2))/5 + 1)^2) - (2^(1/2)*10^(1/2))/(100*((2^(1/2)*10^(1/2))/5 + 1)))/(4/(5*((2^(1/2)*10^(1/2))/5 + 1)^2) + 1);
y = @(x) y1(x(1),x(2),x(3));
Neelanjan Pal on 25 Apr 2020
y =
function_handle with value:
@(x)y1(x(1),x(2),x(3))
Only this is showing and nothing else.

VBBV on 5 Sep 2021
Edited: VBBV on 5 Sep 2021
syms kp ki l
y= ((1/10^(l + 1)*ki*kp*l*sin((pi*l)/2))/(kp + (ki*kp*cos((pi*l)/2))/10^l) - (1/10^(l + 1)*ki^2*kp^2*l*cos((pi*l)/2)*sin((pi*l)/2))/(10^l*(kp + (ki*kp*cos((l*pi)/2))/10^l)^2))/((1/10^(2*l)*ki^2*kp^2*sin((pi*l)/2)^2)/(kp + (ki*kp*cos((l*pi)/2))/10^l)^2 + 1) - (1/(25*((2^(1/2)*10^(1/2))/5 + 1)^2) - (2^(1/2)*10^(1/2))/(100*((2^(1/2)*10^(1/2))/5 + 1)))/(4/(5*((2^(1/2)*10^(1/2))/5 + 1)^2) + 1);
yy = subs(y,[kp ki l],[x(1) x(2) x(3)])