0

I have two handle-functions, their graphs are very close to each other, I can see this by plotting both functions.

f = @(x1);
ff = @(x2);
fplot(f, [0 1],'r')
hold on
fplot(ff, [0 1],'b')
hold on

I would like to have another graph where I take the difference between f-ff

fplot((f-ff), [0 1])

how can I do this in matlab? And how can I find the:

max(abs(f-ff))

when both are handle-functions?
Thanks in advance!

PS. Just let me know if I should add more info about f and ff.

Sergio Haram
  • 437
  • 4
  • 17

1 Answers1

1

Try this:

fplot(@(x) f(x) - ff(x), [0 1])
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • Hi @LuisMendo, thanks for your answer, I was wondering if you have a suggestion to how can I find `max(abs(f-ff))`? – Sergio Haram Feb 25 '14 at 12:49
  • 1
    You could do it numerically: define your `x` values: `x=linspace(0,1,1e5);` and then compute `max(abs(f(x)-ff(x)))`. Or you could use `fplot(@(x) abs(f(x)-ff(x)), [0 1])` and see the result graphically – Luis Mendo Feb 25 '14 at 13:13