Errors with Quad function

4 vues (au cours des 30 derniers jours)
Shawna Myatt
Shawna Myatt le 24 Nov 2018
Modifié(e) : Shawna Myatt le 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)

Réponse acceptée

madhan ravi
madhan ravi le 24 Nov 2018
Modifié(e) : madhan ravi le 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 commentaires
Shawna Myatt
Shawna Myatt le 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 le 24 Nov 2018
Modifié(e) : madhan ravi le 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by