0

In the first scenario link the solution provided was excellent and it did work. However I tried to make it work with another function and I ended up with nothing close to what is expected. My code so far:

yn = [-1.20449 -1.14398 -1.02273 -0.962285 -0.90203 -0.841474 -0.780881...
-0.720346 -0.659896 -0.579599 -0.539505 -0.478662 -0.418963 -0.35859...
-0.299039 -0.238886 -0.179108 -0.118999 -0.058841 -0.006249 -0.06189...
0.006332 0.04056 0.11813 0.1776723 0.238403 0.29827 0.358396...
0.418149 0.4786 0.478154 0.538114 0.53862 0.598954 0.659804...
0.720267 0.781026 0.8412 0.901548 0.962022 1.022567 1.083291...
1.143653];
xn = linspace(-22,22,43)';
yn = yn';
fn = fit(xn,yn,'poly1')

figure()
hold all
plot(fn,xn,yn)
yn_fit = f(xn);
error = yn - yn_fit;
figure()
plot(xn, error,'k')

I would appreciate any help.

Community
  • 1
  • 1
sayid jetzenden
  • 153
  • 1
  • 11

0 Answers0