Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. clear all; close all; clc;
  2.  
  3. % Raw data
  4. x = [1.3 1.8 3 4.5 6 8 9];
  5. y = [0.07 0.13 0.22 0.275 0.335 0.35 0.36];
  6.  
  7. % Initialises order and gets values from function
  8. order = 2;
  9. [F, V, a0, a1, r2] = LinRegrSGR(x, y, order);
  10.  
  11. % Prints values found in function
  12. fprintf('F: %f\n',F);
  13. fprintf('V: %f\n',V);
  14. fprintf('a0: %f\n',a0);
  15. fprintf('a1: %f\n',a1);
  16. fprintf('r2: %f\n',r2);
  17.  
  18. % Sets the annonymous function
  19. a = @(m) (F.*m.^order)./(V.^order + m.^order);
  20.  
  21. % Plots the values according to the correct format
  22. plot(x,y,'rs');
  23. hold on;
  24. domain = 1:0.1:10;
  25. plot(domain,a(domain),'b--');
  26. legend('Raw Data','Curve fit','location','northwest');
  27. xlabel('Mass (m)')
  28. ylabel('Acceleration (a)')
  29. title('Mass vs Acceleration Graph')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement