% Script/Function Filename:uicontrol
%     curvePlotterGUI.m
% Purpose:
%     Enter the purpose of the function/file here
%
% Record of modifications:
%     Programmer(s): {Your Name}
%     Date Due: YYYY-MM-DD
%     Date Submitted: YYYY-MM-DD
%     References: ????
%     Help Received: ????
%
% Variables Used:
%     Enter the variables that you use here

allCoeffs = [ -10 : -1 1 : 10 ];
n = 3;
coeffs = allCoeffs( randi( 20 , n , 1 ) );
temp = coeffs';
allXs = linspace( -10 , 10 , 100 );
x = sort( allXs( randperm( 100 , n ) ) );

xMat = repmat( x' , 1 , length( coeffs ) );
[ powers , ~ ] = meshgrid( ( n - 1 ) : -1 : 0 );

y = ( ( xMat .^ powers ) * temp )';

solvedCoeffs = solveSystem( x , y );

scatter( x , y , 20 , 'k' );
x = allXs;
hold on;
equation = coefficients2equation( solvedCoeffs );
plot( x , eval( equation ) , 'r-' );
drawnow;
equation2 = coefficients2equation( coeffs );
plot( x , eval( equation2 ) , 'g-' );
drawnow;
hold off;
axis tight;