Filter löschen
Filter löschen

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

18 Ansichten (letzte 30 Tage)
Sergey Dukman
Sergey Dukman am 9 Sep. 2015
Kommentiert: Steven Lord am 9 Sep. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 9 Sep. 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 Kommentare
Sergey Dukman
Sergey Dukman am 9 Sep. 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 am 9 Sep. 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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Optimization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by