Trying to use quad to solve this integral but keep getting error

2 次查看(过去 30 天)
y = @(x)((1.941-24.3*x).^2)/(2.92*(0.02408-x)*(0.01605-x));
%Using quad to calculate integral
time = quad(y,0,0.01204);
display(time);
This is the error I get
Error in HW7Q2>@(x)((1.941-24.3*x).^2)./(2.92*(0.02408-x)*(0.01605-x))
Error in quad (line 67)
y = f(x, varargin{:});
Error in HW7Q2 (line 4)
time = quad(y,0,0.01204);

回答(1 个)

Roger Stafford
Roger Stafford 2016-4-7
You've forgotten the dot in your division. It should be:
y = @(x)((1.941-24.3*x).^2)./(2.92*(0.02408-x)*(0.01605-x));

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by