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

조회 수: 14(최근 30일)
Robert Scott
Robert Scott 2021년 8월 13일
댓글: Paul 2021년 8월 15일
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
Robert Scott
Robert Scott 2021년 8월 13일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 8월 14일
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
Star Strider
Star Strider 2021년 8월 14일
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:
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:
fplot(@(t)yfcn([1,1,0,0,1],t), [0 15])
Then calculate the necessary characteristics from the estimated function.

댓글을 달려면 로그인하십시오.

추가 답변(3개)

Paul 2021년 8월 14일
I'm not sure what you mean by "fall time," so can't help you there.
Why isn't
sufficient? Is the data too noisy or something?
  댓글 수: 1
Paul 2021년 8월 15일
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.

댓글을 달려면 로그인하십시오.

Robert Scott
Robert Scott 2021년 8월 15일
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
Image Analyst
Image Analyst 2021년 8월 15일
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.

댓글을 달려면 로그인하십시오.

Robert Scott
Robert Scott 2021년 8월 15일
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
Star Strider
Star Strider 2021년 8월 15일
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.

댓글을 달려면 로그인하십시오.




Community Treasure Hunt

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

Start Hunting!

Translated by