Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all; close all; clc;
- % Raw data
- x = [1.3 1.8 3 4.5 6 8 9];
- y = [0.07 0.13 0.22 0.275 0.335 0.35 0.36];
- % Initialises order and gets values from function
- order = 2;
- [F, V, a0, a1, r2] = LinRegrSGR(x, y, order);
- % Prints values found in function
- fprintf('F: %f\n',F);
- fprintf('V: %f\n',V);
- fprintf('a0: %f\n',a0);
- fprintf('a1: %f\n',a1);
- fprintf('r2: %f\n',r2);
- % Sets the annonymous function
- a = @(m) (F.*m.^order)./(V.^order + m.^order);
- % Plots the values according to the correct format
- plot(x,y,'rs');
- hold on;
- domain = 1:0.1:10;
- plot(domain,a(domain),'b--');
- legend('Raw Data','Curve fit','location','northwest');
- xlabel('Mass (m)')
- ylabel('Acceleration (a)')
- title('Mass vs Acceleration Graph')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement