Errors with Quad function

조회 수: 2 (최근 30일)
Shawna Myatt
Shawna Myatt 2018년 11월 24일
편집: Shawna Myatt 2018년 11월 24일
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