Step Response
Show older comments
a=[0.2,0.4,0.5,0.7,2,1]
g = (tf(1, [1 2*a 1]));
S= stepinfo(g)
This is a step response problem where as you can see 'a' is the variable to be multiplied. I know that we can solve this by using the stepinfo(g)and the step information with display the results automatically.
My question is how does matlab calculate the results?
% RiseTime: 1.1308
% SettlingTime: 38.7087
% SettlingMin: 0.4685
% SettlingMax: 1.7292
% Overshoot: 72.1625
% Undershoot: 0
% Peak: 1.7292
% PeakTime: 3.1416
I got these numbers by doing this:
a= 0.1
g= tf(1,[1 2*a, 1])
[ y, t ] =step(g) % default of 60 seconds
S = stepinfo(y,t)
plot ( t, y )
So you can solve this for any values, how can use indexing within the transfer function?
Now I need to just label each, do we need to input calculations just use
function S=stepinfo(y,t)
Frequency response:
a=[0.2,0.4,0.5,0.7,2,1]
g = (tf(1, [1 2*a 1]));
a=[0.2;0.3;0.4;0.7;1;2]'
H =(tf(1, [1 2*a(index) 1]));
bode(H,{0.1,10})
My goal here is to graph the freq response for all values so I am thinking to subplot and index also. I am not sure how this can be done with Bode.
This works, I double checked but can I index and subplot for 6 values?
a=0.1
H =(tf(1, [1 2*a 1]));
bode(H,{0.1,10})
Any information will help, I am just going in circles, mean while I will be reading the book again and again.
Gabriel
Answers (1)
Arnaud Miege
on 19 Apr 2011
First, a comment: it would help if your question was properly formatted. As it is, it's very difficult to read.
If I understand your question correctly, the best way is probably to use a for loop:
a=[0.2,0.4,0.5,0.7,2,1];
for k=1:length(a)
g(k) = tf(1,[1 2*a 1]);
[y(k,:), t(k,:)] = step(g(k));
S(k) = stepinfo(y(k,:),t(k,:));
end
This grows the variables in a loop, so is not exactly best practice, but it should work:
>> S(1).RiseTime
ans =
0.8600
You can then pass the whole g to the bode command:
bode(g,{0.1,100})
or again, do this in a loop if you want to do them one by one.
HTH,
Arnaud
5 Comments
Gabriel
on 19 Apr 2011
Arnaud Miege
on 19 Apr 2011
Looking at the documentation for the stepinfo function (http://www.mathworks.com/help/releases/R2011a/toolbox/control/ref/stepinfo.html), you can specify a different settling time ratio from the default 2%.
Arnaud Miege
on 19 Apr 2011
S = stepinfo(...,'SettlingTimeThreshold',ST) lets you specify the threshold ST used in the settling time calculation. The response has settled when the error |y(t) - yfinal| becomes smaller than a fraction ST of its peak value. The default value is ST=0.02 (2%).
Gabriel
on 19 Apr 2011
Arnaud Miege
on 20 Apr 2011
bode is from the Control System Toolbox, whereas freqs is from the Signal Processing Toolbox. bode allows you to compute/display the Bode plot (magnitude & phase) of any LTI system (Linear-Time Invariant), transfer function, zero-pole gain or state-space system. freqs, on the other hand, only displays/computes the frequency response of an analog filter.
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!