code explanation question help!
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
william Smith
el 1 de Abr. de 2019
Comentada: william Smith
el 1 de Abr. de 2019
%can you please explain what this code is calcuating?
%Thanks!
y= x(find(t > t(i)-0.3))
0 comentarios
Respuesta aceptada
Adam Danz
el 1 de Abr. de 2019
Editada: Adam Danz
el 1 de Abr. de 2019
'i' is an integer, index value. For the sake of the example, let's say i = 4.
t(i) is the 4th value stored in 't'.
t > t(i)-0.3 produces a logical vector of 1s and 0s the same size as 't'. It contains 1s whenever the value of t is greater than the 4th t plus 0.03.
So, if t = [0 1 2 3 4 5 6 7] and i = 4, the logical vector would be [0 0 0 1 1 1 1 1].
find() returns the index values that are true. so, find([0 0 0 1 1 1 1 1]) would return [4,5,6,7,8].
x([4,5,6,7,8]) looks at the fourth, fifith, sixth, seventh, and eighth values of 'x'.
To summarize, that line pulls out a subsection of 'x' based on the values of 't'.
9 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!