x is 100x1. Now, suppose we want to generate multiple terms of the form sin(k*w*x), so k will be a vector. w is a fixed constant. Do you know how to do that?
Ok, so what does this do in MATLAB?
This is just effectively a multiplication table. But do you see that it forms what you need? You can now compute sin(x*w*k), and cos(x*w*k).
In your case, x is a column vector, of size 100x1. Your code might look like:
P = [ones(size(x)),sin(x*w*k),cos(x*w*k)];
Now, the only problem is, all the sin terms are bundled together, then all the cos terms. If that bothers you, then reshuffle those columns. Something like this should work.
P(:,[2:2:end,3:2:end]) = P(:,[2:n+1,n+2:end]);
Now the sin and cos terms alternate.