Built-in data fitting feature in MATLAB (lsline & basic fitting in figure menu)
Prerequisite:
Multiple Linear Regression | MATLAB Machine Learning using MATLAB: https://www.matlabcoding.com/2020/04/standard-deviation-in-matlab-without.html lsline Documentation: https://in.mathworks.com/help/stats/lsline.html
Code:
Multiple Linear Regression | MATLAB Machine Learning using MATLAB: https://www.matlabcoding.com/2020/04/standard-deviation-in-matlab-without.html lsline Documentation: https://in.mathworks.com/help/stats/lsline.html
Code:
%Regression analysis on the grade, the IQ, and the number of
hours studied per week by 13 students
clc
clear all
close all
format longG
%Grade
y=[1 1.6 1.2 2.1 2.6 1.8 2.6 2 3.2 2.6 3 3.6 1.9];
%IQ
x1=[110 112 118 119 122 125 127 130 132 134 136 138 125];
%Study Time
x2=[8 10 6 13 14 6 13 12 13 11 12 18 7];
n=length(x1);
a=[ones(n,1) x1' x2'];
c=pinv(a)*y';
No comments