Uff!!!. I think I finally found a solution to this. I will not assure this is the best way to do it.
clear all;
global X;
global Y;
global n;
global var2;
global var1;
global c;
X=[0;5;10;20;30;50;100;200;300;400;500;600;700;800;1000;1200];
Y=[0.96;0.88;0.85;0.82;0.8;0.78;0.73;0.69;0.65;0.61;0.57;0.54;0.51;0.48;0.39;0.21];
c=[.961 .04 .868 1204.2 1.996e-4];
n = length(X);
err=2.8929e-05;
Sigma_f2 = zeros(n,1);
This above part is only for initialization. The next part is used for calculation. I have defined the function names as per their function. Previously defined global variables are used in the functions below.
Square = @Calculate_ydiff_square;
Sum = @Summation;
Pdf = @(te1,te2)(2*exp(-(1/(2*err^2)))* Sum(te1,te2));
IntegralProduct = @(te1,te2)(Square(te1,te2).*Pdf(te1,te2));
for k =1:n
var1 = X(k);
var2 = Y(k);
Sigma_f2(k)=integral2(IntegralProduct,3.76E-02,4.19E-02,1.72E-04,2.25E-04)/((2*pi*err)^(n/2));
end
function y_diff_square = Calculate_ydiff_square(te1,te2)
global var2;
global c;
global var1;
y = (c(1)-te1*asinh((c(3)^2*var1) / (1-var1/c(4))) - te2*var1);
y_diff_square = (y - var2).^2;
end
function SumVal = Summation(te1,te2)
SumVal = 0;
global X;
global Y;
global n;
global c;
for k=1:n
var1 = X(k);
var2 = Y(k);
SumVal = SumVal + ((c(1)-te1*asinh((c(3)^2*var1) / (1-var1/c(4))) - te2*var1) - var2).^2;
end
end
I am still not sure with the solution. please let me know if this works fine
The reason why matrix cannot be used in integration is during integration Matlab makes its own matrix for all the values in the range of the integrals!. So having a Input matrix of different size cannot be processed,
:)
Best Answer