How to plot a function obtained after integrating a two-parameter function with respect to one parameter?

y=0:0.01:1;
f=@(t,y) exp(-t.*y);
q=@(y) integral(@(t) f(t,y),0,2);
g=@(t,y) sin(t.*y);
p=@(y) integral(@(t) g(t,y),2,4);
k=q(y)+p(y);
M=cos(y);
L=M.*k
plot(y,L)
The actual functions are a bit different but they have the same parameters and I have followed the same procedure. I am neither getting values of L nor the plot. I also tried ezplot and fplot. ezplot shows error and fplot gives a blank plot.

 Accepted Answer

Use symbolic toolbox
syms y t
f=exp(-t*y)
q=int(f,t,0,2)
p=int(g,t,2,4)
k=q+p
M=cos(y)
L=M*k
fplot(y,L,[0 1])

More Answers (1)

y=0:0.01:1;
f=@(t,y) exp(-t*y);
q=integral(@(t) f(t,y),0,2,'ArrayValued',true);
g=@(t,y) sin(t*y);
p=integral(@(t) g(t,y),2,4,'ArrayValued',true);
k=q+p;
M=cos(y);
L=M.*k;
plot(y,L)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!