basisN0 = @(x)[ 1 ];basisN1 = @(x)[ 1, x ];basisN2 = @(x)[ 1, x, x^2 ];basisN3 = @(x)[ 1, x, x^2, x^3 ];
When I use the command size(), I am told that all of these variables are 1×1, while I need them to be 1×1,1×2,1×3 and 1×4.
f = @(x)x;basisN0 = { 1 };basisN1 = { 1, f };basisN2 = { 1, f, f^2 };basisN3 = { 1, f, f^2, f^3 };
I also tried inputting the variables like this but am told that I cant square and cube the function handle.
f = @(x)x;fsqr = @(x)x^2;fcub = @(x)x^3;basisN0 = { 1 };basisN1 = { 1, f };basisN2 = { 1, f, fsqr };basisN3 = { 1, f, fsqr, fcub };
Lastly, I tried this approach and achieved the correct array sizes. However, I had to utilize three different function handles and cannot plug in numbers to the arrays. For example, basisN3(5) would not give me [1 5 25 125]. Please help explain how I would input these variables to achieve my desired outcome.
Best Answer