How can I enter this integral?

3 views (last 30 days)
sharif
sharif on 14 Mar 2014
Commented: Walter Roberson on 16 Mar 2014
hm=1.5;
t= 0:-0.1:-1;
m=100;
n=1:1:m;
Fs=zeros(length(t),length(n));
FEM=zeros(length(t),length(n));
for ii=1:length(t)
for jj = 1:length(n);
Lm=76.3-10*log10(hm);
x=(-1j*t(ii)*sqrt(m-n)*sqrt(2/pi)+0.5);
y=(exp(-t*srt(n-m)))/(sqrt(2j));
S=int(sin(y),y=0..x);% how can I use this integration??
C=int(cos(y),y=0..x);
Fs(x)=y(S+1j*C);
FEM(ii,jj)= (1/n)*sum(Lm(t(ii))*Fs);
end
end

Accepted Answer

Walter Roberson
Walter Roberson on 14 Mar 2014
int() is used only for symbolic integration. You use integral() or older equivalents for numeric integration. integral() should be passed a function handle.
For example, to numerically integrate sin(t) over 0 to 2, one could use
integral(@(t) sin(t), 0, 2)
In your code you have a series of problems caused by using vectors. Your "n" is a vector, so sqrt(m-n) is going to be a vector so your x is going to be a vector and your y is going to be a vector. Then you try to integrate the vector sin(y) over y from 0 to x, but x is a vector and y has already been defined through a formula.
With you trying to use y as a variable of integration when y is defined by a formula, are you implicitly wanting to solve for the "t" such that the expression for y at that value of t gives you each value from 0 to x ?
If you have a fixed numeric vector of values, you would use trapz() or a similar integral approximation routine.
  4 Comments
sharif
sharif on 15 Mar 2014
matlab 10 is the one i am using, I will first try to solve the integral problem and then I will try to solve the others, thanks for help
Walter Roberson
Walter Roberson on 16 Mar 2014
I believe integral() was introduced in R2011-something. Before that see quad() or quadgk()

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!