# Rlocusplot provide gain K

**URL:** https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578
**Category:** Modelling & Simulations
**Tags:** package, controlsystems
**Created:** [October 31, 2022, 7:43pm UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578 "2022-10-31T19:43:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![GottDengDirk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gottdengdirk/32/43952_2.png) [@GottDengDirk](https://discourse.julialang.org/u/GottDengDirk)
#### Post date: [October 31, 2022, 7:43pm UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/1 "2022-10-31T19:43:13Z")

</div>

Hello,

i have a problem that i want to provide K for rlocusplot, but it does no work.  
thanks in advance

using ControlSystems  
w0=2\*pi  
D=0.1  
Ki=0.05

sys = Ki_w0^2/(s^3+2_D_w0_s^2+w0^2_s+Ki_w0^2)

k=range(1e-6,stop=1000,length=20000)  
#k=(0.001:0.001:1000)  
rlocusplot(sys, k, xlims=(-4,4), ylims=(-10, 10))

---

<div class="post-metadata">

### Author: ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)
#### Post date: [October 31, 2022, 11:14pm UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/2 "2022-10-31T23:14:42Z")

</div>

Could you provide some details of what is not working, e.g. which error message you get?

Guessing from the code you gave, it seems there are many multiplication signs missing and also the definition of `s`, i.e. it should look more like

```julia
s = LinRange(-4,4, 20000) # or whatever range s has...
sys = @. Ki * w0^2 / (s^3 + 2D*w0*s^2 + s*w0^2 + Ki * w0^2)

```

At this point we can only guess what `s` is, but if it is a vector, then you need to add `@.` in front to make sure all operations are applied component-wise. (See also [Mathematical Operations and Elementary Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/mathematical-operations/#man-dot-operators))

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [November 1, 2022, 5:08am UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/3 "2022-11-01T05:08:14Z")

</div>

`rlocusplot` has the following docstring

> Computes and plots the root locus of the SISO LTISystem P with a negative feedback loop and feedback gains between 0 and `K`. `rlocusplot` will use an adaptive step-size algorithm to determine the values of the feedback gains used to generate the plot.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [November 1, 2022, 5:09am UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/4 "2022-11-01T05:09:37Z")

</div>

The OP does not contain this information, but `s` is the Laplace-transform s, created using

```julia
s = tf('s')

```

There are still some multiplications missing in the expression in the OP.

---

<div class="post-metadata">

### Author: ![GottDengDirk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gottdengdirk/32/43952_2.png) [@GottDengDirk](https://discourse.julialang.org/u/GottDengDirk)
#### Post date: [November 1, 2022, 7:54pm UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/5 "2022-11-01T19:54:45Z")

</div>

yes. There are some Probleme, when i copy the code.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/a/9af6d338dec38038455d59e6f5e5b6cea42ced16.png)  
My confusion lies in the use of K in the function. I tried providing a value for K to increase the range of the root, but none of it changed the original Plot.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [November 1, 2022, 8:23pm UTC](https://discourse.julialang.org/t/rlocusplot-provide-gain-k/89578/6 "2022-11-01T20:23:13Z")

</div>

You might have to change the `xlims, ylims` of the plot manually
