I want to integrate the following over the interval x0 = 0:2:8 . I have tried using arrayfun:
x0 = 0:2:8;cai= @(theta) ((4.*pi.*x0.*cos(theta).*sin(theta)+8.*pi.*cos(theta).*cos(theta).*sin(theta))./(1+0.5.*x0+cos(theta))); xval = arrayfun(@(uplim) integral(cai, 0, uplim, 'ArrayValued',true), x0);plot(x0, xval)grid
But I got the following error code:
Error using arrayfunNon-scalar in Uniform output, at index 1, output 1.Set 'UniformOutput' to false.Error in PlottingFx (line 6)xval = arrayfun(@(uplim) integral(cai, 0, uplim, 'ArrayValued',true), x0);
Can anyone help me?
Best Answer