[Error: Function definition not supported in this context. Create functions in code file
Show older comments
clc; clear;
% dy = zeros(2,1); % y(1) = y ; y(2) = dy
% y = y(1);
% dy(1) = y(2);
% dy(2) = t- 4*y(2)-4*y(1);
f = @(t,y) [y(2) ; t- 4*y(2)-4*y(1)];
%-----------------------------------------
% To slove the BVP by the shooting method.
x = 0.5;
x1 = fzero(F,x);
%-----------------------------------------
% The problem are here ! ! ! I have a problem that I have been thinking about for a long time and still can't solve.
% To slove the ODE by ode45.
function F = solver(x);
options = odeset ('RelTol', 1e-8, 'AbsTol',[1e-8, 1e-8]);
[t,y] = ode45(f, [0 1], [1 x], options);
F = y(length(t),1)-1;
end
%----------------------------------------
figure(1);
plot(t,y(:,1));

Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!