From 717ea8c7881a7e3ef9a0c545d23e9eebf797494b Mon Sep 17 00:00:00 2001 From: neingeist Date: Thu, 6 Nov 2014 12:13:13 +0100 Subject: [PATCH] Polynomial feature mapping --- ex5/polyFeatures.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ex5/polyFeatures.m b/ex5/polyFeatures.m index f496f48..f80ce7c 100644 --- a/ex5/polyFeatures.m +++ b/ex5/polyFeatures.m @@ -10,15 +10,13 @@ function [X_poly] = polyFeatures(X, p) X_poly = zeros(numel(X), p); % ====================== YOUR CODE HERE ====================== -% Instructions: Given a vector X, return a matrix X_poly where the p-th +% Instructions: Given a vector X, return a matrix X_poly where the p-th % column of X contains the values of X to the p-th power. % -% - - - - - +% +for i = 1 : p + X_poly(:,i) = X .^ i; +end % =========================================================================