Errors with Quad function

4 Ansichten (letzte 30 Tage)
Shawna Myatt
Shawna Myatt am 24 Nov. 2018
Bearbeitet: Shawna Myatt am 24 Nov. 2018
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)

Akzeptierte Antwort

madhan ravi
madhan ravi am 24 Nov. 2018
Bearbeitet: madhan ravi am 24 Nov. 2018
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 Kommentare
Shawna Myatt
Shawna Myatt am 24 Nov. 2018
Thank you! Somehow we have talked about .^ in class but we have never talked about ./ being used as well.
madhan ravi
madhan ravi am 24 Nov. 2018
Bearbeitet: madhan ravi am 24 Nov. 2018
Anytime :) , make sure to accept the answer if it helped you and also be familiar with matlab's element wise operations ,
see

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by