Errors with Quad function

4 次查看(过去 30 天)
I am getting an error that I don't know how to fix. Here is the problem that I started with and the error messages that I am getting. Any help would be wonderful!
Question:
The following integral arises in the study of reaction-diffusion equations. It describes the width of repeating patterns in periodic steady state solutions. T(µ) = integral from 0 to 1 of ( µ / sqrt ( F(µ)−F(µz) ) dz. µ is a fixed constant with 0 < µ < 1 and F(x) = x^2 / 2 − x^3 / 3. Find T(0.01) using quad. My professor said that the F(x) is what we need to use µ in, which we will then put into the sqrt in our equation. We have to create a formula where z is the only variable so that we can use that with the quad function.
Errors that I am getting:
Error using /
Matrix dimensions must agree.
Error in
Homework_7>@(z)(mu/(sqrt(((((mu).^2)/2)-(((mu).^3)/3))-((((mu*z).^2)/2)-(((mu*z).^3)/3)))))
Error in quad (line 67)
y = f(x, varargin{:});
Error in Homework_7 (line 82)
quad(Tmu, 0, 1)

采纳的回答

madhan ravi
madhan ravi 2018-11-24
编辑:madhan ravi 2018-11-24
put ./ instead of / usually integral is preferred than quad see doc
>> mu = 0.01
Tmu = @(z)(mu ./ (sqrt(((((mu).^2)/2) - (((mu).^3)/3)) - ((((mu*z).^2)/2) - (((mu*z).^3)/3)))))
integral(Tmu, 0, 1) %changed quad to integral
mu =
0.0100
Tmu =
function_handle with value:
@(z)(mu./(sqrt(((((mu).^2)/2)-(((mu).^3)/3))-((((mu*z).^2)/2)-(((mu*z).^3)/3)))))
ans =
2.2309
>>
  2 个评论
Shawna Myatt
Shawna Myatt 2018-11-24
Thank you! Somehow we have talked about .^ in class but we have never talked about ./ being used as well.
madhan ravi
madhan ravi 2018-11-24
编辑:madhan ravi 2018-11-24
Anytime :) , make sure to accept the answer if it helped you and also be familiar with matlab's element wise operations ,
see

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by