Skip to main content
8-Gravel
March 16, 2025
Solved

"solve" inside a programm

  • March 16, 2025
  • 2 replies
  • 809 views

hello everyone, let's see if you can help me. It turns out that I want to plot a root locus.
It turns out that I have to solve the equation [1+ K G(s)* H(s)= 0] for each K.
For a given K I can do it with solve: for example:
G(s):=10/(s^2+2*s+10) and H(s):=5/(s+5) for a k:=3 gives me the following result.

R:[-7.75;0.375-5.07i;0.375+5.07i]

how do I get the same within a program by varying k by different values?

 

Best answer by Werner_E

You could use a numeric solve block with "find" and turn it into a function dependent on k and then call this function (as every other function) from within your program.

A numeric solve block will only give you just one solution depending on the guess value provided.

If you need all three solutions and you used the symbolic "solve" command, you can try to turn this symbolic evaluation into a function of k.

Here in Mathcad 15:

Werner_E_0-1742174785052.png

 

For further help you will have to attach your worksheet and specify in more detail what exactly you need and intend to do.

2 replies

Werner_E25-Diamond IAnswer
25-Diamond I
March 17, 2025

You could use a numeric solve block with "find" and turn it into a function dependent on k and then call this function (as every other function) from within your program.

A numeric solve block will only give you just one solution depending on the guess value provided.

If you need all three solutions and you used the symbolic "solve" command, you can try to turn this symbolic evaluation into a function of k.

Here in Mathcad 15:

Werner_E_0-1742174785052.png

 

For further help you will have to attach your worksheet and specify in more detail what exactly you need and intend to do.

hegel8-GravelAuthor
8-Gravel
March 18, 2025

wonderful

23-Emerald IV
March 17, 2025

And if you have that function f(k) as Werner shows, you can plot the loci of s on the complex plane:

LucMeekes_0-1742235845629.png

Success!
Luc