calculate/pich up x-value from step function

2 views (last 30 days)
Olga Rakvag
Olga Rakvag on 21 Feb 2023
Answered: Sam Chak on 21 Feb 2023
How I can easiest calculate/pick up x value for r63 and r98 prosent av full scale?
clc; clear all; close all;
% 1 order step respons
Gain=0.999*5;
np = tf([5*0.999], [0.000999, 1])
t = linspace(0, 0.1, 1000);
r63= 5*Gain*0.632;% 63prosent of final value
r98=5*Gain*0.98; % 98 prosent of final value
figure(1)
step(np,'k')
hold on
% 63 and 98 % of full scale
yline( r63,'r-',' 63%', 'LabelHorizontalAlignment','left'); hold on
yline( r98,'r-','98%', 'LabelHorizontalAlignment','left'); hold on
xlim([0, 0.01])
ylim([0.7, 5.5])
grid on
hold off
  1 Comment
Oguz Kaan Hancioglu
Oguz Kaan Hancioglu on 21 Feb 2023
You can use stepinfo command to find time response of the given system. https://www.mathworks.com/help/ident/ref/lti.stepinfo.html

Sign in to comment.

Answers (1)

Sam Chak
Sam Chak on 21 Feb 2023
% 1st-order step response
Gain = 0.999*5;
np = tf(Gain, [0.000999, 1])
np = 4.995 -------------- 0.000999 s + 1 Continuous-time transfer function.
r63 = Gain*0.632 % 63 percent of the final value
r63 = 3.1568
r98 = Gain*0.98 % 98 percent of the final value
r98 = 4.8951
figure(1)
t = linspace(0, 0.1, 1001);
y = step(np, t); % generate the output values for y
plot(t, y) % make a plot of the step response
% step(np,'k') % or put at this line also can
hold on
% 63 and 98 % of full scale
yline(r63, 'r-', ' 63%', 'LabelHorizontalAlignment', 'left');
yline(r98, 'r-', ' 98%', 'LabelHorizontalAlignment', 'left');
xlim([0, 0.01])
ylim([0, 5.5])
grid on
hold off
% Time it takes to go from 0 to r63
idx1 = find(y > 0.99*r63 & y < 1.01*r63)
idx1 = 11
y(idx1) % y value closest to r63 = 3.1568
ans = 3.1593
T63 = t(idx1) % around 0.001 sec
T63 = 1.0000e-03
% Time it takes to go from 0 to r98
idx2 = find(y > 0.999*r98 & y < 1.001*r98)
idx2 = 40
y(idx2) % y value closest to r98 = 4.8951
ans = 4.8943
T98 = t(idx2) % around 0.039 sec
T98 = 0.0039
Note that the computation of the Step Response Characteristics changes in version R2021b.
Make that you understand before using stepinfo()
stepinfo(np)
ans = struct with fields:
RiseTime: 0.0022 TransientTime: 0.0039 SettlingTime: 0.0039 SettlingMin: 4.4955 SettlingMax: 4.9949 Overshoot: 0 Undershoot: 0 Peak: 4.9949 PeakTime: 0.0105

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by