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

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

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

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

funny, i was just trying that. Thanks for mentioning it.
Although i am having a hard time creating the data from my time domain data. Not sure exactly what is up yet but i think this is a path forward.
You wouldnt happen to know how to build the iddata set from a vector with time domain data in it would you?
Thank you
well, not having much luck. I created the iddata object and was able to plot it. It looks correct except the x and y axis seem to be on different plots?
I want the rise and fall time of that data. The only think i can do is step the system but that does seem to give me the rise and fall time. it gives me the rise and fall time of the step response but what i need is the rise and fall time of the original system.
Not sure what im doing wrong.
You wouldnt happen to know how to build the iddata set from a vector with time domain data in it would you?
I would.
Ideally, it is necessary to supply the input, output, and sampling interval, although only the output and sampling interval are absolutely required. The data need to be regularly (consistently) sampled (and obviously at the same sampling frequency and sampling times), so if they are not, use the Signal Processing Toolbox resample function on each to create a regularly-sampled vector. (I can help with that as well, if you need me to.) The sampling interval in that instance is the inverse of the sampling frequency, that you would supply as an argument to the resample function.
Once you have those vectors, ssest then requires thaty the numbers of poles (order) be specified, and will welcome any other information you want to share with it. (There are other options as well, such as tfest, however I prefer ssest because state space systems are much easier to work with and understand, at least in my experience. Use the tf fucntion to convert the state space system to a transfer function, if necessary, although I generally find that it isn’t.)
When the system is estimated, use the compare function to see how well the estimated system matches the data. Tweak as required to get the best fit.
.
great info
So here is what i have. All pre requisites i think are made
The data is regularly sampled. Its data from an o scope
So i have 62500 samples.
My data consists of a y data and x data. x being the time and y being the result.
What i did was the following.
data = iddata( y_data_vector, [] , time_stamps_max - time_stamps_min)
so im just finding the sampling interval by taking the delta of my time stamps. Is that right?
Then i was just taking a guess at the order.
so i did
system = ssest (data,2)
That seems to give me a transfer function. However then im not sure where to go to get the info i want.
the ssest function seems to give me back a model.
However, the rise and fall time info is obviously wrong
the tfest function is throwing an error saying index value exceeds 0 which i dont understand and that is all the info it gives me. Im feeding it the same iddata object im giving to ssest
So not sure what is going on.
So here is the reason why i think something is wrong.
when i do stepinfo(system)
I see a rise time of of like "23299"
Im not sure how that would be possible given the time delta on the data is only 2 mili seconds
It would be helpful to have your data.
so im just finding the sampling interval by taking the delta of my time stamps. Is that right?
That is not the correct delta.
This would be better:
data = iddata( y_data_vector, [], time_stamps(2) - time_stamps(1))
.
ok so its the sampling interval not the total time of the data collected
ok that makes sense.
So let me ask you this
I have redone the code with that adjustment.
Im seeing a rise time and fall time of something greater then the length of time of my entire test. How is that even possible?
I cant share the data unfortuneatley.
So i think this is the problem
I dont want the rise and fall time of the step response. I want the rise and fall time of the curve i provided to the iddata
Any thoughts on that?
This is going to be difficult because I don’t even know that the data look like, so I’m not sure what ‘rise time’ and ‘fall time’ are.
I’m now thinking that this is a square wave. In that situation, the Signal Processing Toolbox risetime and falltime and related functions might be appropriate. (I’m not certain that the System Identification or Control System Toolboxes have functions that can estimate those, since they’re not usually properties of such systems.)
.
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
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)

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

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.

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

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.

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

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

Asked:

on 13 Aug 2021

Commented:

on 15 Aug 2021

Community Treasure Hunt

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

Start Hunting!