find overshoot, undershoot, rise time and fall time on a non step response function

80 views (last 30 days)
So i know i can do this with a step response plot
But say i have a continuous time doman plot aka just a vector of data
I want to find rise and fall time over shoot and undershoot
are there any built in functions for this?
  2 Comments
Robert Scott
Robert Scott on 13 Aug 2021
yes and i can write the code to for a sum and a subtraction but there is functions in matlab for that also. The very concept of a functions is to produce reusable code. That is very nature of programming.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 14 Aug 2021
Use the System Identification Toolbox functions such as iddata and ssest to identify and estimate the system. Then, use stepinfo on the identified system to get the information you want.
.
  12 Comments
Robert Scott
Robert Scott on 14 Aug 2021
not a square wave, just picture a typical 2nd order step response. Little overshoot and settles in one oscilation or so.
I tried the rise time measurment but it returns an empty string.
Not having much luck tonight
Star Strider
Star Strider on 14 Aug 2021
Edited: Star Strider on 15 Aug 2021
I wish you could share the data.
At least then I’d have some idea of what the problem is.
Well, at least the square wave possibility is no longer an option. I considered that when I realised tthat ‘fall time’ might be exactly that, rather than ‘settling time’ that I initially assumed (and that turned out to be correct).
Is the compare function giving any useful information as to how well the estimated system matches the data?
Perhaps simulating the input ‘u(t)’ if you have an idea of what it is, and giving that to iddata (and ssest) would make this easier. Also, experiment with the other arguments and name-value pair arguments to include delays and other options.
If you want to get a more general idea of the system characteristics, one possibility would be to take the fft of the signal. Plotting the imaginary part of the fft as a function of frequency would tell you how many poles and zeros there are, and approximately where they are, including those at the origin and infinity. Use the one-sided fft for this. The ssest function allows a range of orders that it can the experiment with, so that could be an option as well, however the imaginary fft plot would allow you to see them yourself and to see if it truly is a second-order system.
I doubt that tfest would provide any better estimate than ssest (since in my experience, ssest is the most robust option), however it could be worth trying. I have no idea what else to suggest at this point.
———
EDIT — (15 Aug 2021 at 14:48)
The only other approach I can suggest is to fit the data to a function using one of the nonlinear parameter estimation routines (fminsearch, lsqcurvefit, nlinfit, fitnlm, or others). That function derivation could be:
syms f(t) y(t) t p y0 Dy0 f0
p = sym('p',[1,2]);
Dy = diff(y);
D2y = diff(Dy);
Eqn = D2y + p(1)*Dy + p(2)*y == f0;
ys = dsolve(Eqn, Dy(0)==Dy0, y(0)==y0);
ys = simplify(expand(ys), 500);
yfcn = matlabFunction(ys, 'Vars',{[p(1),p(2),y0,Dy0,f0],t})
yfcn = function_handle with value:
@(in1,t)exp(in1(:,1).*t.*(-1.0./2.0)).*1.0./sqrt(in1(:,2).*-4.0+in1(:,1).^2).*(in1(:,4).*sinh((t.*sqrt(in1(:,2).*-4.0+in1(:,1).^2))./2.0).*2.0+in1(:,3).*cosh((t.*sqrt(in1(:,2).*-4.0+in1(:,1).^2))./2.0).*sqrt(in1(:,2).*-4.0+in1(:,1).^2)+in1(:,1).*in1(:,3).*sinh((t.*sqrt(in1(:,2).*-4.0+in1(:,1).^2))./2.0))-(in1(:,5).*exp(in1(:,1).*t.*(-1.0./2.0)).*1.0./sqrt(in1(:,2).*-4.0+in1(:,1).^2).*(cosh((t.*sqrt(in1(:,2).*-4.0+in1(:,1).^2))./2.0).*sqrt(in1(:,2).*-4.0+in1(:,1).^2)-exp((in1(:,1).*t)./2.0).*sqrt(in1(:,2).*-4.0+in1(:,1).^2)+in1(:,1).*sinh((t.*sqrt(in1(:,2).*-4.0+in1(:,1).^2))./2.0)))./in1(:,2)
with ‘in1’ the parameter vector corresponding to (in order): [p(1),p(2),y0,Dy0,f0] .
A representative plot of that (with estimated parameters being simulated here) would likely be something like this:
figure
fplot(@(t)yfcn([1,1,0,0,1],t), [0 15])
grid
Then calculate the necessary characteristics from the estimated function.
.

Sign in to comment.

More Answers (3)

Paul
Paul on 14 Aug 2021
I'm not sure what you mean by "fall time," so can't help you there.
Why isn't
stepinfo(y,t)
sufficient? Is the data too noisy or something?
  1 Comment
Paul
Paul on 15 Aug 2021
I'm still not sure why stepinfo() isn't useful for your application.
As I understand the problem, you have some data and you wish to find some figures-of merit of the data. I'm still under the impression that the data is essentially the output of a system that was excited by a step input.
Why am I under that impression? Because:
a) the figures of merit overshoot, undershoot, and rise time are commonly used to describe the output of a system in response to a step input. I'm not familiar with "fall time" but a quick search suggests it's essentially the same as the rist time
b) this answer, which you seemed to be pursuing, suggested using the function stepinfo(), which is used to estimate the figures of merit you seek for the output of a system in response to a step input
c) in this comment you explicitly said to "picture a typical 2nd order step response."
Based on the above, I'm assuming you have some data that looks like a "typical 2nd order step response." For what I'm sure are good reasons, you can't show us the data. So let's create some
sys = tf(1,[1 2*.7 1]); % 2nd order system for experimenting
stepinfo(sys) % get the figures of merit based on the model
ans = struct with fields:
RiseTime: 2.1268 SettlingTime: 5.9789 SettlingMin: 0.9001 SettlingMax: 1.0460 Overshoot: 4.5986 Undershoot: 0 Peak: 1.0460 PeakTime: 4.4078
[y,t] = step(sys); % generate some data
stepinfo(y,t) % gneerate the same figures of merit based on data
ans = struct with fields:
RiseTime: 2.1190 SettlingTime: 6.0895 SettlingMin: 0.9001 SettlingMax: 1.0460 Overshoot: 4.8126 Undershoot: 0 Peak: 1.0460 PeakTime: 4.4078
As expected, the FOMs based on the data closely match what stepinfo caclulates based on the model.
Does this example capture the essence of what you're trying to do?
If not, you'd probably get more traction here if you posted an example of what you're trying to accomplish with some actual data. Not the real data in question if you can't share it, but some example data that sitll illustrates the problem.

Sign in to comment.


Robert Scott
Robert Scott on 15 Aug 2021
TYhe problem persists. The issue is, i dont want the rise and fall time of the step response. I want the rise and fall time of the data itself. To do the ssest and then take the step response is not correct.
I am not trying to model a system and then see the step response of it. I want to see the rise and fall time of the data i have not the step response of the data i have.
That is the different.
Picture this, working with an o scope, when you do a single trigger and get a plot, you can hit the "measure"button on every scope on earth. You can select rise and fall time and it will go off and mark the rise and fall time of the plot.
That is all im trying to do
  1 Comment
Image Analyst
Image Analyst on 15 Aug 2021
How about this instead:
"Picture this -- see the screenshot below of my data plotted."
And then indicate with red lines or arrows exactly what x and y distances you want to measure between.

Sign in to comment.


Robert Scott
Robert Scott on 15 Aug 2021
its fine, i have given up. As with many many things in matlab, what should be easy and take 5 minutes in python takes 5 hours of frustration.
I have just given up trying to find this data. I tried to do something a bit more manual using poly fit and doing some calculus on it but in order to approximate the curve correctly i need to go out to the 10th order plus which makes doing this via derivitives uselss
Since i am giving up on this one, can you guys lend a hand with this new problem i have discovered. I am disapointed that i even have to ask this one.
  1 Comment
Star Strider
Star Strider on 15 Aug 2021
Just out of curiosity, what were you able to do with Python that you could not do with MATLAB?
I am still not certain what the problem is with the data. If it is noisy, one option could be the Savitzky-Golay filter sgolayfilt function that generally works and is preferable for broadband noise where frequency-selective filters completely fail. (Select 3 for the order, then experiment with the frame length to get the best result.) The smoothdata function can slso use it, however it is apparently necessary to have the Signal Processing Toolbox to use it with smoothdata.
.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!