Borrar filtros
Borrar filtros

How to define the value of "t" from function f(t)

18 visualizaciones (últimos 30 días)
Sergey Dukman
Sergey Dukman el 9 de Sept. de 2015
Comentada: Steven Lord el 9 de Sept. de 2015
Hello,
I have a function
f(t)=exp(-0.01*t.^2).*cos(2.*t)
where 't' is a function handle (f=@t)
I need to define 't' when f(t)=0.4.
How do I do this?
Sergey

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Sept. de 2015
It sounds to me like you might be attempting to solve exp(-0.01*t.^2).*cos(2.*t) to find the t where the expression becomes 0.4 . If so then there are an infinite number of solutions. You can find one of them by using
syms f(t)
f(t) = exp(-0.01*t.^2).*cos(2.*t);
vpasolve(f(t)=0.4)
  2 comentarios
Sergey Dukman
Sergey Dukman el 9 de Sept. de 2015
Hello, Yes, you are right. I need to find t when f(t)=0.4. Thank you for help!
Sergey
Steven Lord
Steven Lord el 9 de Sept. de 2015
Or if you don't have Symbolic Math Toolbox, you could use FZERO from MATLAB. Rewrite your expression so it's in the form g(t) = 0:
f = @(t) exp(-0.01*t.^2).*cos(2.*t);
g = @(t) f(t)-0.4; % Transforming f(t) = 0.4 -> f(t)-0.4 = 0
Then call FZERO to find a zero of g(t). Change the initial guess to locate additional zeros.
fzero(g, 0)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by