how to remove error form BVP4C code
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Monte Carlo Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!