how to remove error form BVP4C code
Show older comments
Respected Sir/Maam.
I was trying to solve a Nonlinear System ODE by BVP4C. Hear It is error " Error in bvp4c (line 129)" in File "marwah (attached)" and some errors, which i am not able to rectify. Can you please help. If any information is required, please feel free to ask.
Thanking you in Advance
you help will be highly apprecialbe.
% Define the values of M for which we want to solve the ODE
M_values = [0, 0.5, 1, 1.5, 2];
% Loop over the different values of M
for i = 1:length(M_values)
M = M_values(i);
% Define the anonymous functions for the ODEs
ode1 = @(eta, y) [y(2); y(3); -(y(2)^2) - y(1)*y(3) + M*y(2)];
ode2 = @(eta, y) [y(3); -2*y(2)*y(3) - 2*y(1)*y(2)];
% Define the boundary conditions
bc = @(ya, yb) [ya(1); ya(3); ya(2)-1; yb(1); yb(2); yb(3)];
% Solve the ODEs using bvp4c
eta_vals = linspace(0, 10, 1000);
init_guess = [0, 1, -1];
solinit = bvpinit(eta_vals, init_guess);
sol = bvp4c(ode1,bc,solinit);
f = sol.y(1,:);
fp = sol.y(2,:);
g = sol.y(3,:);
% Plot the graphs of f(eta), f'(eta), and g(eta)
figure;
plot(eta_vals, f, 'b', 'LineWidth', 1.5);
hold on;
plot(eta_vals, fp, 'r', 'LineWidth', 1.5);
plot(eta_vals, g, 'g', 'LineWidth', 1.5);
legend('f(eta)', 'f''(eta)', 'g(eta)');
title(['M = ', num2str(M)]);
xlabel('eta');
ylabel('f(eta), f''(eta), g(eta)');
grid on;
end
Accepted Answer
More Answers (0)
Categories
Find more on Monte Carlo Analysis 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!