// Scilab file made available as part of TEQIP-NCM-NBHM workshop: Nov 2019
//Tested on scilab version 6.0.1
// Conducted at IIT Bombay. Scilab scripts written by Sudarshan Pulapadi
// License: GPL


//Pseudo_inverse

//--> find inverse of matrix
A = [1 2 3; 4 5 6;8 7 10];
inv(A)

//--> for non-square or singular matrices find pseudo inverse
A = [1 2 3; 2 4 6;3 6 9];
pinv(A)



//Least_square_fit
A = [1 2 3; 4 5 6;8 7 10];
b = [0.3 0.5 0.7] ;

//--> find x than minimizes least square error between Ax-b 
x = pinv(A)*b'





