How to calculate the maximum distance between two functions

Hello guys i have a test on matlab coming up in the university , one of the exercises is probably going to be to calculate the maxium distance between two functions.
ex.
f1=cos(x) f2=sin(x) x=[0,4pi]
find the x for which the distance between f1 and f2 is maximum

Answers (1)

Torsten
Torsten on 28 Nov 2018
Edited: Torsten on 28 Nov 2018
x = fminbnd(@(x)-(sin(x)-cos(x))^2,0,4*pi)
distance = abs(sin(x)-cos(x))

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 28 Nov 2018

Edited:

on 28 Nov 2018

Community Treasure Hunt

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

Start Hunting!