What is the purpose of the input argument 'Tolerance' in the risetime function?
4 views (last 30 days)
Show older comments
Samuel Foster
on 16 Apr 2025
Commented: William Rose
on 17 Apr 2025
The function 'risetime' has an optional input argument 'Tolerance' that as far as I can tell has no affect on the functionality.
In the code below I load some step data and then call the function with and without the 'Tolerance' argument. This gives me the same answer. I also call the function with the 'Tolerance' argument but without the 'PercentReferenceLevels' argument. Since the functions defaults to the values [10, 90] this also gives me the same answer.
load('Step_data.mat')
tol = 1; % User defined tolerance
ipt = findchangepts(Step_data(:,2)); % Find step change index
% Find statelevels
Q1 = Step_data(ipt-1,2);
Q2 = Step_data(ipt,2);
Statelvls = sort([Q1,Q2]);
% Call the function with and without the 'Tolerance' input argument
[Reac_t_1, Reac_l_t_1, Reac_u_t_1, Reac_ll_1, Reac_ul_1] = risetime(Step_data(:,3),'StateLevels',Statelvls,'PercentReferenceLevels', [10,90],'Tolerance',tol);
[Reac_t_2, Reac_l_t_2, Reac_u_t_2, Reac_ll_2, Reac_ul_2] = risetime(Step_data(:,3),'StateLevels',Statelvls,'PercentReferenceLevels', [10,90]);
[Reac_t_3, Reac_l_t_3, Reac_u_t_3, Reac_ll_3, Reac_ul_3] = risetime(Step_data(:,3),'StateLevels',Statelvls,'Tolerance',tol);
My understanding of this function is that it is picking the points marked with crosses in the attached graph. These two points are defined by the input argument 'PercentReferenceLevels', so why the need for a 'Tolerance' input argument? What extra info could this provide to the function that would affect its output?
0 Comments
Accepted Answer
William Rose
on 16 Apr 2025
Here's an example of tolerance making a difference:
t=0:999;
x=(mod(t/100,2)>=1 & mod(t/100,6)<5)+0.8*(mod(t/100,6)>=5);
x=x+0.2*(rand(size(x))-0.5); % add noise
%plot(t,x,'-r.')
risetime(x,PercentReferenceLevels=[20 80])
risetime(x,PercentReferenceLevels=[20 80],Tolerance=19)
In the first case, with default value for tolerance, there were four risetimes. The third "high" state was not high enough to get recognized as a transition to the high state. When the tolerence is larger (second call to risetime), there were five risetimes, because the third high state WAS recognized as high. Tolerance defines the levels that must be reached in order to qualify as "making it into the state". And if the signal does make it into that state, then the Reference Levels are used, along with interpolation, to determine when the transitions happened.
3 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


