%% Problem 1 on the take home exam. % I'm giving you some partial commands below so that you can just fill % them in and run the code- Note that the code will not run correctly % until you do fill them in. % % Be sure and download the Matlab data file to a directory with this m-file load Exam1THQ1; % This loads X (100 x 3) and Xtest (10 x 2). %% Set up the matrix for the least squares problem as Ax = b % % Think about it column-wise, where the x's are in the first column, X(:,1), % the y's are in the second column, X(:,2), and the z's (the outputs) % are in the third column, X(:,3). A=[ ]; % Fill this command in - As a hint, A should be 100 x ? b=X(:,3); % I'll give you this one xhat= ; % Fill this command in - This is the least squares solution % If A was correctly assembled above, this line should work without change. Atest=[Xtest(:,1).^2, Xtest(:,1).*Xtest(:,2), Xtest(:,2), sin(Xtest(:,2)), ones(10,1)]; z=Atest*xhat %%