MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by Hassan on 13 Oct 2012

I have a vector represent a step change, and I want to calculate the time constant of it, "the time it takes to reach 63%". the vector that represent the step change is as below:

y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000 0.0001 0.0006 0.0029 0.0108 0.0266 0.0583 0.1212 0.2361 0.3877 0.5089 0.6059 0.6833 0.7453 0.7948 0.8343 0.8660 0.8913 0.9115 0.9276 0.9405 0.9509 0.9591 0.9657 0.9710 0.9752 0.9786 0.9813 0.9834 0.9851 0.9865 0.9876 0.9885 0.9892 0.9898 0.9902 0.9906 0.9909 0.9911 0.9913 0.9914 0.9915 0.9916 0.9917 0.9918 0.9918 0.9918 0.9919 0.9919 0.9919 0.9919 0.9920 0.9920

if you made a plot to the Y vector in the matlab it will give you step function from 0 to 0.9405, I just want to calculate the time it takes to reach 0.63 from the step, which by eye can be detrmind at aprox. 27

I need a formula to calculate it automatically please advise

*No products are associated with this question.*

Answer by Azzi Abdelmalek on 13 Oct 2012

Edited by Azzi Abdelmalek on 13 Oct 2012

Accepted answer

yi=y(end) idx=max(find(abs(y-yi)>=0.37*yi))

% `idx` the corresponding index

Answer by Ákos on 18 Feb 2013

Hi!

I have an input and an output vector, for example:

in=[0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1]

out=[0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 2; 12; 17; 20; 21; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22]

If you want to see it in a figure, type the following code to the Command Window:

in=[0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1]; out=[0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 2; 12; 17; 20; 21; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22; 22]; x=(1:1:30); plot(x,in,'red') hold plot(x,out,'blue') hold

I would like to determinate the delay and the time constant. I have System Identification Toolbox, and I can determinate the delay in GUI mode (Td=2.864), but I would like to determinate it in a matlab script. Which functions have to use, and how? Maybe I have to use the delayest function, but it doesn't works in this way:

DATA=iddata(out,in,0.1) delayest(DATA)

The result is 0.

So I think this is not the right way. Can somebody write me an example to this two vector?

Thanks in advance!

Azzi Abdelmalek on 18 Feb 2013

Ákos, This is expected to be an answer. If you want to get more chance to have an answer, post a new question.

## 2 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/50688#comment_104885

Please examine the guide to tags and retag this question; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/50688#comment_104886

You mean 63% from the

y(end)