function [y,out,w]=train_B_splines(InpPat,TarPat,x_min,x_max,order,Knots,n_Knots,n_fun,train) [m,n]=size(InpPat); for i=1:m out(i,:)=basis_out(InpPat(i,:),x_min,x_max,order,Knots,n_Knots,n_fun); end if train w=pinv(out)*TarPat; y=out*w; else y=0; w=0; end