x0=0;x1=1/2;x2=1;>> L0 = @(x)((x-x1).*(x-x2)/((x0-x1)*(x0-x2)))L0 = @(x)((x-x1).*(x-x2)/((x0-x1)*(x0-x2)))>> L1 = @(x)((x-x0).*(x-x2)/((x1-x0)*(x1-x2)))L1 = @(x)((x-x0).*(x-x2)/((x1-x0)*(x1-x2)))>> L2 = @(x)((x-x0).*(x-x1)/((x2-x0)*(x2-x1)))L2 = @(x)((x-x0).*(x-x1)/((x2-x0)*(x2-x1)))>> f = @(x) sin(pi*x/2)./((1+x).^(1/2))f = @(x)sin(pi*x/2)./((1+x).^(1/2)) t=0:0.01:1 p = @(x)(f(x0)*L0+f(x1)*L1+f(x2)*L2)p = @(x)(f(x0)*L0+f(x1)*L1+f(x2)*L2)>> p(t)Undefined function 'mtimes' for input arguments of type 'function_handle'.Error in @(x)(f(x0)*L0+f(x1)*L1+f(x2)*L2)
MATLAB: What’s going on about the code?? I used the same code the teammate used, but mine keep showing error
can anyone tell me what's wrong about my f function and could you explain why it happens? thank you
Best Answer