MATLAB: Representation of array

m-fileMATLABsimulink

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?

Best Answer

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.