0
如果我是集成的功能如何整合,有許多參數的函數使用MATLAB
Y = - ((F + H)立方公尺(COSH(H * M)+ M (h * M))/(h * M * cosh(h * M)+( - 1 + h * M^2 * beta)* sinh(h * M)) - (alpha *(M^2 *(F + h)*( - 1 + 2 * h^2 * M^2 + cosh(2 * h * M)-2 * h * M * sinh(2 * h * M)))/( 8 *(H * M * COSH(H * M)+( - 1 + H * M^2 *測試版)*的sinh(H * M))^ 2));
相對於x,其中
phi = 0.6;
x = 0.5;
M = 2;
theta = -1:0.5:1.5;
F = theta - 1;
h = 1 + phi*cos(2*pi*x);
alpha = 0.2;beta = 0.0;
我寫了一個M文件
function r = parameterIntegrate(F,h,M,beta,alpha,theta,phi)
% defining a nested function that uses one variable
phi = 0.6;
x = 0.5;
r = quad(@testf,0,1 + phi*cos(2*pi*x));
% simpson's rule from 0 to h
function y = testf(x)
h = 1 + phi*cos(2*pi*x);
theta = -1:0.5:1.5;
F = theta - 1;
M = 2;
beta = 0;
alpha = 0;
y = -((F+h)*M^3*(cosh(h*M)+M*beta*sinh(h*M)))/(h*M*cosh(h*M)+(-1+h*M^2*beta)*sinh(h*M))- (alpha*(M^2*(F+h)*(-1+2*h^2*M^2+ cosh(2*h*M)-2*h*M*sinh(2*h*M)))/(8*(h*M*cosh(h*M)+(-1+h*M^2*beta)*sinh(h*M))^2));
end
end
和
tol = [1e-5 1e-3];
q = quad(@parameterIntegrate, 0, h,tol)
or
q = quad(@parameterIntegrate, 0,1 + phi*cos(2*pi*0.5),tol)
調用的函數它不工作了給我
Error using ==> plus
Matrix dimensions must agree.
謝謝。我嘗試了第3步,我仍然得到相同的信息。我會嘗試檢查代碼中的每一行。 – sani 2012-03-18 16:48:22
謝謝pearsonartphoto,我現在知道這個問題。 – sani 2012-03-20 08:37:46