MATLAB: How to enter this integral

integrals

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

Best Answer

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.