Enginius/Matlab
syms + ezplot = rocks!
해리s
2011. 10. 27. 00:58
Problem. plot contours of the cost function J in the parameter space
- 매트랩 코드
%% clear all
- 매트랩 코드
%% clear all
clear all;
close all;
clc; % clear screen
%% load data
data = load('hw01_data1.dat');
input = data(:, 1:2);
target = data(:, 3);
% (a) get optimal value of the parameter vector
parameter = pinv(input)*target;
parameter %print parameter vector
% (b)
cov_input = cov(input);
[V, D] = eig(cov_input);
V %print e.vector of cov
D %print e.value of cov
%plot contours of the cost function J in the parameter space
syms p1;
syms p2;
p = [p1 ; p2];
J = (target - input*p)'*(target - input*p) - 1;
ezplot(J, [4.6 5.4 -1.8 -1]);