To design the function x_m(x,m)
, follow these steps:
out
with size N x (M+1)
x
into the first d
columns of out
. This can be done using indexing and slicing, as shown in the code below.out
, from column d+1
to column M+1
.x
to the power of its column index minus d
(or simply use the built-in power
function in MATLAB) and set the corresponding column of out
to the result. This can also be done using indexing and slicing.Here's the code implementation in MATLAB:
main.m468 chars17 lines
You can now call this function with any input data matrix x
and any value of M
to produce the desired output matrix of size N x (M+1)
.
gistlibby LogSnag