1 view (last 30 days)

I am having trouble with the integral part in Am=2/delta_a.*integral(Phi_o.*cos(Bm.*x),-delta_a/2,delta_a/2) and am wondering how I would be able to rewrite this with a function handle or an alternative.

D=2;

Ea=0.1;

vEf=0.12;

delta_a=10*pi;

v=0.22;

Phi_o=1;

t=1;

x1=(-delta_a/2:delta_a/2);

n=1:2:5;

Bm=n*(pi/delta_a);

lambdam=v*(D*(Bm.^2)+Ea-vEf);

Am=2/delta_a.*integral(Phi_o.*cos(Bm.*x),-delta_a/2,delta_a/2);

Phi=sum(Am*cos(Bm.*x1).*exp(-lambdam*t));

Shubham Gupta
on 28 Oct 2019

Edited: Shubham Gupta
on 28 Oct 2019

Using some info from this question, which you have posted again. My understanding is that you want to calculate Phi at each n & Bm, Am, & lambam varies according to n(1,3,5). After calculating Phi(n) for each n you are adding by using Phi=Phi1+Phi3+Phi5. You can try following to achieve this:

D=2;

Ea=0.1;

vEf=0.12;

delta_a=10*pi;

v=0.22;

Phi_o=1;

t=1;

x1=(-delta_a/2:0.1:delta_a/2);

x2=x1';

n=1:2:5;

Bm=@(n)n*(pi/delta_a);

lambdam=@(n)v*(D*(Bm(n).^2)+Ea-vEf);

f = @(n)@(x)Phi_o.*cos(Bm(n)*x);

Am = @(n)(2/delta_a.*integral(f(n),-delta_a/2,delta_a/2));

Phif = @(n)(Am(n)*cos(Bm(n).*x2).*exp(-lambdam(n)*t));

Phi = sum(cell2mat(arrayfun(Phif,n,'Uniformoutput',false)),2);

plot(x2,Phi)

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/487758-problem-with-computing-integral-of-a-function#comment_760661

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/487758-problem-with-computing-integral-of-a-function#comment_760661

Sign in to comment.