본문 바로가기

Enginius/Matlab

syms + ezplot = rocks!

Problem. plot contours of the cost function J in the parameter space 

- 매트랩 코드 
%% 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]);

 

'Enginius > Matlab' 카테고리의 다른 글

Matlab에서 "Out of Memory" 해결하기  (5) 2012.05.24
newff  (0) 2011.11.07
eig (Eigenvalue and Eigenvector)  (0) 2011.10.27
mldivide \, mrdivide / (Matrix division)  (0) 2011.10.26
hist (Histogram)  (0) 2011.10.26