Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Get t co-ordinate based off y co-ordinate

1 visualización (últimos 30 días)
Jamie Ford
Jamie Ford el 15 de Oct. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I am trying to get the t co-ordinate of the following graph when y = 40
t = 0 * pi:0.119:4 * pi;
a = 57;
phase_angle = 0.26;
y = a*sin((67*pi*t) + phase_angle);
plot(t,y);
so i want the co-ordinate (t, 40)
how can I get t?
Thanks

Respuestas (1)

Star Strider
Star Strider el 15 de Oct. de 2019
Try these:
t = 0 * pi:0.119:4 * pi;
a = 57;
phase_angle = 0.26;
y = a*sin((67*pi*t) + phase_angle);
y_ofst = y-40;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
y40 = zci(y_ofst);
for k = 1:numel(y40)
idxrng = y40(k)+[-1,1]
B = [t(idxrng); ones(size(t(idxrng)))].' \ y_ofst(idxrng).' % Linear Regression
xxct(k) = -B(2)/B(1)
end
figure
plot(t,y, xxct,40+[0 0],'pg')
alternatively:
for k = 1:numel(y40)
idxrng = y40(k)+[-1,1]
xxct(k) = interp1(y(idxrng), t(idxrng), 40) % Interpolation
end
figure
plot(t,y, xxct,40+[0 0],'pg')
Choose the most appropriate option for your application. Both give the same result.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by