Just wondering if you could guide me on how to find the characteristic equation of a trasfer function G(s) (see below for G(s)) in terms of the coefficients in the PI controller?
G(s) = 45/(5s + 2)
No sure what to do here, as I'm used to just multiplying the error by the proportional gain - but there's no error value provided.
Any advice would be much appreciated. Thanks in advance ;)
Given:
G(s) = 45/(5s + 2) (plant transfer function)
C(s) = Kp + Ki/s (PI Controller transfer function)
and assuming your system looks like:
https://www.dropbox.com/s/wtt4tvujn6tpepv/block_diag.JPG
The equation of the closed loop transfer function is:
Gcl(s) = C(s)G(s)/(1+C(s)G(s)) = CG/(1+CG)
In general, If you had another transfer function on the feedback path, H(s),
the the closed loop transfer function becomes:
CG / (1 + CGH)
If you plug in G(s) and C(s) as shown above you will get the following closed loop transfer function after some algebraic simplification:
45*[Kp*s + Ki] / [5*s*s + (2 + 45*Kp)*s + 45*Ki]
and so the characteristic equation is
5*s*s + (2 + 45*Kp)*s + 45*Ki = 0
Notice how the integral term adds a pole to the system but has a side effect of also adding a zero which could produce unwanted transient behaviour if Kp is not chosen correctly. The presence of Kp in the s term in the denominator shows that the value of Kp will determine the damping ratio of the system and therefore determine the transient response.
More information on poles, zeros, and system dynamics:
http://web.mit.edu/2.14/www/Handouts/PoleZero.pdf
Related
I am using Fortran to solve some coupled PDEs using finite-differences and spectral methods. At a certain point those grids are fed into FFTW.
I assume the domain is periodic and I am struggling to find the most efficient way to deal with the problem of indexing. Options:
1 - Ghost Cells:
I define my grids as
real :: y(0:nx+1,0:ny+1)
(do finite differences)
call update_ghost(y)
Problem :
when I use FFTW I want the input to be the grid without the ghost cells, so I do:
call fftw(phi(1:nx,1:ny),phi_k)
and this leads to temporary array creation since the data is not contiguous.
2 - Indirect Adressing:
real :: y(nx,ny)
I then calculate vectors with the coordinates of the neighbours taking into account PBC then do
do j=1,ny
do i=1,nx
laplacian(i,j) = y(xnext(i),j) + y(xprev(i),j) + ...
enddo
enddo
Problem: Indirect Adressing is expensive
3 - Calculate indices inside the loop
do j=1,ny
do i=1,nx
xnext = modulo(i+2,nx) + 1
ynext = modulo(i,nx) + 1
xprev = modulo(j+2,ny) + 1
yprev = modulo(j,ny) + 1
laplacian(i,j) = y(xnext,j) + y(xprev(i),j) + ...
enddo
enddo
Problem: extra calculations
Does anyone have any other options? Right now I use option 1 but it kills me to think of all the temporary array creation that is happening behind the scenes.
I have a sigmoidal looking set of data for protein unfolding. I want to find enthalpy (H), mid temperature(Tm), and 4 other variables (ad,bd,an,bn) with a non-linear model.
My data are T for temperature and y for the circular dichroism signal (for percentage folded).
Here is the equation:
k = exp((H/(R*T))*(T/Tm - 1));
y = ((ad + bd*T)/(1 + k) + (an + bn*T)*k/(1 + k));
I tried:
fit=lsqcurvefit(T,y,'Y')
It didn't work. Any suggestions?
that is because the cost function does not have the global minimum. Eventually the algorithm finds just a local minimum. Try to modify and fit this one x/sqrt(1+x^2)
I am having some trouble to find or implement an algorithm to find a signal source. The objective of my work is to find the sound emitter position.
To accomplish this I am using three vibration sensors. The technique that I am using is multilateration that is based on the time difference of arrival.
The time difference of arrival between each sensor are found using Cross Correlation of the received signals.
I already implemented the algorithm to find the time difference of arrival, but my problem is more on how multilateration works, it's unclear for me based on my reference, and I couldn't find any other good reference for this that are free/open.
I saw this post Trilateration using TDOA
But I can't figure out how to solve the set of equations(7) of the wikipedia page of multilateration as i have only the three TDOA.
Any help on this would be much appreciated
You have three sensor coordinates A,B,C, unknown coordinate of signal source P, unknown time of signal start t0, and three times of signal registration ta, tb, tc.
Example: Let's sensor A caught a signal in 12:00:05, sensor B - in 12:00:00, sensor C - 12:00:07. So assign time differences: ta=5, tb=0, tc=7
Squared distances from sensors to source correspond to times of signal walk with velocity v (speed of sound in air or another environment)
(Ax-Px)^2 + (Ay-Py)^2 = (v*(ta-t0))^2 {1}
(Bx-Px)^2 + (By-Py)^2 = (v*(tb-t0))^2 {2}
(Cx-Px)^2 + (Cy-Py)^2 = (v*(tc-t0))^2 {3}
Open the brackets, then subtract equations ({2}-{1}, {3}-{2},{1}-{3}) to discard squares of unknown terms.
Ax^2-2*Ax*Px + Px^2 + Ay^2-2*Ay*Py + Py^2 = v^2*(ta^2 - 2*ta*t0 + t0^2)
Bx^2-2*Bx*Px + Px^2 + By^2-2*By*Py + Py^2 = v^2*(tb^2 - 2*tb*t0 + t0^2)
Cx^2-2*Cx*Px + Px^2 + Cy^2-2*Cy*Py + Py^2 = v^2*(tc^2 - 2*tc*t0 + t0^2)
Bx^2-Ax^2 -2*(Bx-Ax)*Px + By^2-Ay^2 -2*(By-Ay)*Py = v^2*(tb^2-ta^2 -2*(tb-ta)*t0) {1'}
Cx^2-Bx^2 -2*(Cx-Bx)*Px + Cy^2-By^2 -2*(Cy-By)*Py = v^2*(tc^2-tb^2 -2*(tc-tb)*t0) {2'}
Ax^2-Cx^2 -2*(Ax-Cx)*Px + Ay^2-Cy^2 -2*(Ay-Cy)*Py = v^2*(ta^2-tc^2 -2*(ta-tc)*t0) {3'}
Now you have system of three linear equations with three unknowns. It might be solved with some widespread algorithms - Gauss elimination, LU decomposition etc.
Note that solution precision strongly depends on small errors in coordinates and time measurements (this method is not very robust).
Geometrically, a hyperbola represents the cloud of points with a constant difference in distance between two points. You have 3 points, but taken pairwise, the time differences between the 3 possible pairs will allow you to draw 3 hyperbolas. Look for a spot at or between where the hyperbolas intersect on a plot. Or solve the equivalent algebra (least squares).
I am running a speech enhancement algorithm based on Gaussian Mixture Model. The problem is that the estimation algorithm underflows during the training processing.
I am trying to calculate the PDF of a log spectrum frame X given a Gaussian cluster which is a product of the PDF of each frequnecy component X_k (fft is done for k=1..256)
what i get is a product of 256 exp(-v(k)) such that v(k)>=0
Here is a snippet of the MATLAB calculation:
N - number of frames; M- number of mixtures; c_i weight for each mixture;
gamma(n,i) = c_i*f(X_n|I = i)
for i=1 : N
rep_DataMat(:,:,i) = repmat(DataMat(:,i),1,M);
gamma_exp(:,:) = (1./sqrt((2*pi*sigmaSqr_curr))).*exp(((-1)*((rep_DataMat(:,:,i) - mue_curr).^2)./(2*sigmaSqr_curr)));
gamma_curr(i,:) = c_curr.*(prod(10*gamma_exp(:,:),1));
alpha_curr(i,:) = gamma_curr(i,:)./sum(gamma_curr(i,:));
end
The product goes quickly to zero due to K = 256 since the numbers being smaller then one. Is there a way I can calculate this with causing an underflow (like logsum or similar)?
You can perform the computations in the log domain.
The conversion of products into sums is straightforward.
Sums on the other hand can be converted with something such as logsumexp.
This works using the formula:
log(a + b) = log(exp(log(a)) + exp(log(b)))
= log(exp(loga) + exp(logb))
Where loga and logb are the respective representation of a and b in the log domain.
The basic idea is then to factorize the exponent with the largest argument (eg. loga for sake of illustration):
log(exp(loga)+exp(logb)) = log(exp(loga)*(1+exp(logb-loga)))
= loga + log(1+exp(logb-loga))
Note that the same idea applies if you have more than 2 terms to add.
Using mathematica, I can compute the mathematical representation of a function that I then want to code in C++.
Say I get something like:
f=Log[2*x+3*y]+Sin[4*x+6*y]
It obviously makes sense in that case to do the computation:
temp=2*x+3*y
f=Log[temp]+Sin[2*temp]
Is there a way to get the expression that would reduce the execution time / number of operations / size of the expression or any good metric given a more complex mathematical expression?
Although it doesn't work for your simple example, what you can try is the following in Mathematica
Experimental`OptimizeExpression[{Log[(2*x^3 + 3*y)^2] + Sin[2 (2*x^3 + 6*y)^2]}]
As result you get
Experimental`OptimizedExpression[
Block[{Compile`$3, Compile`$4}, Compile`$3 = x^3;
Compile`$4 = 2 Compile`$3;
{Log[(Compile`$4 + 3 y)^2] + Sin[2 (Compile`$4 + 6 y)^2]}]]