Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: December 5, 2026, 2:24 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find the point on the root locus with a certain damping in Octave
#6
RE: How to find the point on the root locus with a certain damping in Octave
(May 14, 2023 at 5:49 am)FlatAssembler Wrote: OK, this C++ program I've made:
Code:
#include <algorithm> #include <complex> #include <fstream> #include <iostream> #include <vector> double prigusenje(std::complex<double> s) { return std::cos(std::arg(-s)); } int main() {  using namespace std;  double potrebno_prigusenje = 0.7;  vector<complex<double>> nule{-0.003515, -1.754},      polovi{0, -20 * 1.754, -1.754, -0.1986, -0.003515};  vector<complex<double>> KMK;  vector<double> argumenti, prigusenja;  double epsilon = 0.001;  for (double x = -1; x < 1; x += epsilon)    for (double y = -4; y < 4; y += epsilon) {      complex<double> s(x, y);      complex<double> brojnik = 1, nazivnik = 1;      for (auto nula : nule)        brojnik *= s - nula;      for (auto pol : polovi)        nazivnik *= s - pol;      complex<double> Gs = brojnik / nazivnik;      if (abs(arg(Gs) * (180 / M_PI) - 180) < 3 * epsilon ||          abs(arg(Gs) * (180 / M_PI) + 180) < 3 * epsilon) {        KMK.push_back(s);        argumenti.push_back(arg(Gs) * (180 / M_PI));        prigusenja.push_back(prigusenje(s));      }    }  ofstream datoteka("KMK.txt");  datoteka << "x\ty\tphi\tdzeta\n";  for (int i = 0; i < KMK.size(); i++) {    complex<double> tocka = KMK[i];    double argument = argumenti[i];    double prigusenje = prigusenja[i];    datoteka << tocka.real() << '\t' << tocka.imag() << '\t' << argument << '\t'             << prigusenje << '\n';  }  datoteka.close();  complex<double> najbolji = *min_element(      KMK.begin(), KMK.end(),      [potrebno_prigusenje](complex<double> prvi, complex<double> drugi) {        return abs(prigusenje(prvi) - potrebno_prigusenje) <               abs(prigusenje(drugi) - potrebno_prigusenje);      });  cout << "prigusenje = " << prigusenje(najbolji) << endl;  cout << "frekvencija = " << abs(najbolji.imag()) << endl;  cout << "x = " << najbolji.real() << endl;  double brojnik = 1, nazivnik = 1;  for (auto pol : polovi)    brojnik *= abs(najbolji - pol);  for (auto nula : nule)    nazivnik *= abs(najbolji - nula);  double pojacanje = brojnik / nazivnik;  cout << "pojacanje = " << pojacanje << endl; }
It prints out the following:
Code:
prigusenje = 0.689481 frekvencija = 0.104 x = -0.099 pojacanje = 0.723288
So, allegedly, for the gain of 0.723288, the damping is equal to 0.689481 (very close to the required damping of 0.7), and the frequency is 0.104 rad/sec. How do I check whether that's true?

Try a little tenderness?

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
Reply



Messages In This Thread
RE: How to find the point on the root locus with a certain damping in Octave - by BrianSoddingBoru4 - May 14, 2023 at 6:44 am

Possibly Related Threads…
Thread Author Replies Views Last Post
  A Technology That Dominionists Will Find Useful Secular Elf 6 2881 June 29, 2015 at 10:48 am
Last Post: Nope



Users browsing this thread: 1 Guest(s)