0
I am asking on this community per this question. Please let me know if this is incorrect and which community I should use.
I am trying to evaluate an integral in Matlab using:
int(x^(2)*sin(n*x),x)
Which will return:
(2*x*sin(n*x))/n^2 - cos(n*x)*(x^2/n - 2/n^3)
I then want to evaluate the result of this integral at specific values (similar to a definite integral, but I do not what to have to recompute the integral over and over again if I need to plug in lots of different points). Is there a way to store the result of the integral as a function? I have tried:
f = @(x) int(x^(2)*sin(n*x), x)
but then if I want to evaluate f
at 0, f(0)
tries to do: int((0)^(2)*sin(n*0), x)
, where I want it to do: (2*(0)*sin(n*(0)))/n^2 - cos(n*(0))*((0)^2/n - 2/n^3)
. Essentially, I want Matlab to take the integral and then evaluate at a certain value, without having to copy and paste the result of the int()
command onto the next line? I would relate this to pipes in Linux, such that I would like to pipe the output of the int()
call to the next line and evaluate its result at a specific value. Is there a way to do this?