How to find the maximum value of constant, so that my function doesnt go over a certain value?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello!
I am working on a unit step function, and what I want to do is to find the maximum value of a constant that keeps my function Y value as close as 1.3 as possible.
This is the function of the code:
function H = transferH(K)
syms s;
% Declaring transfer function G(s)
G = 1/(s*(s+4));
H = (G*K)/(1+G*K);
end
function y = create_y_step(K)
syms s t
H = transferH(K);
y = ilaplace(H*(1/s)); %Unit step
end
Let's say im creating the codeline f = create_y_step(K);
This gives me the output:
1 - exp(-2*t)*(cosh(t*(4 - K)^(1/2)) + (2*sinh(t*(4 - K)^(1/2)))/(4 - K)^(1/2))
What I essentially want to do is finding the appropriate/max K value, so that my funtion above, y = create_y_step_(K) is equal to 1.3.
This is the code im trying to work with:
y = create_y_step(K);
y1 = y;
syms K;
y2 = diff(y1,K) == 1.3;
x = solve(y2,K);
X = max(x);
disp(X);
function H = transferH(K)
syms s;
% Declaring transfer function G(s)
G = 1/(s*(s+4));
H = (G*K)/(1+G*K);
end
function y = create_y_step(K)
syms s t
H = transferH(K);
y = ilaplace(H*(1/s)); %Unit step
end
However the output just becomes
"warning unable to find explicit solution".
I have tried done some manually testing with wolfram and the K value should be around 30-31, but im not getting it correct in matlab sadly.
Would really appreciate any help from here! All answers greatly appreciated!!
3 Kommentare
Paul
am 18 Okt. 2021
Bearbeitet: Paul
am 18 Okt. 2021
As you showed, y is a function of time, t. So what do you mean by "keeps my function Y value as close as 1.3 as possible"? As close as 1.3 as possible at which time? What is the "Y value"? Do you mean you want the steady state value of y(t) to be 1.3? Maybe you want the peak value to be 1.3?
Antworten (1)
Paul
am 18 Okt. 2021
Based on your statement that the answer should be around 30-31, I'm guessing that you want to find the value of K such that the peak value of the step response is 1.3, You can do this in the way that I think you're attempting, except you should start by solving for the time(s), t, when the derivative of y is equal to 0, because that's the time(s) when the function y is at a max or min (or inflection point). The next step I'll leave to you.
However, there is a much simpler approach for a second order system (unless you're required to use the approach you're trying). Just use the closed form expression for the peak value and in a few steps you can solve for K. Here's one reference that might be helpful.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Number Theory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!