representation of array

조회 수: 6 (최근 30일)
Krishnendu Mukherjee
Krishnendu Mukherjee 2012년 1월 26일
there is a vector T=[ 0 .00001 ............ .0001 ]
and the corresponding value at different times are represented by: Y=[ 1 2 ........... 3 ] now if i want to track the value of Y at time T=.00001; then how will i get that? actually in sim(0 command the values are being produced for different times. how to pick up a perticular value at a perticular time?
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2012년 1월 26일
Please provide a small set of sample data/operation/expected results.
Krishnendu Mukherjee
Krishnendu Mukherjee 2012년 1월 27일
there is a model of pid controller.
now im simulating it through sim() command from m-file.
[X T Y]=sim('modelname','timespan');
im using 'timespan' as [0 .01 .1] as like-(Tstart T(outputtime) Tfinal] format.
now the output of the pid controller is being tabulated in matlab base window as
>>T=[ 0
.01
.1]
Y=[ 2.35
3.01
3.11 ]
X=[.767 .767 .8765 ................]
now, thing is that i have to return the value of the output(Y) for the time T(outputtime).how will i get that?

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

채택된 답변

Dr. Seis
Dr. Seis 2012년 1월 26일
Like this example?
>> T = 0 : 0.01 : 0.05
T =
0 0.0100 0.0200 0.0300 0.0400 0.0500
>> Y = rand(size(T))
Y =
0.9493 0.3479 0.4887 0.3533 0.7126 0.2021
>> Y_track = Y(T == 0.02)
Y_track =
0.4887
I think there is a better way to do this... since equalities for floating point numbers are generally not good programming practice due to precision issues.
  댓글 수: 3
Krishnendu Mukherjee
Krishnendu Mukherjee 2012년 1월 27일
there is a model of pid controller.
now im simulating it through sim() command from m-file.
[X T Y]=sim('modelname','timespan');
im using 'timespan' as [0 .01 .1] as like-(Tstart T(outputtime) Tfinal] format.
now the output of the pid controller is being tabulated in matlab base window as
>>T=[ 0
.01
.1]
Y=[ 2.35
3.01
3.11 ]
X=[.767 .767 .8765 ................]
now, thing is that i have to return the value of the output(Y) for the time T(outputtime).how will i get that?
Dr. Seis
Dr. Seis 2012년 1월 27일
I haven't worked with "sim"... if "outputtime" is simply an index of time "T" and the time elements in "T" correspond to amplitude elements in "Y", then Y(outputtime) should correspond to T(outputtime). If "outputtime" is a floating point number, then try:
Y_output = Y(int32(T*1e6) == int32(outputtime*1e6))

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by