Code not showing any result or any error
1 次查看(过去 30 天)
显示 更早的评论
clc
clear all
close all
e = 0.1;
M_min = 0;
M_max = 2 * pi;
N = 20;
function [E, M] = kepler_plot(e, M_min, M_max, N)
f = @(E) E - e * sin(E) - M;
M = linspace(M_min, M_max, N);
E = fzero(f, 0, M);
plot(M, E)
xlabel('Mean Anomaly')
ylabel('Eccentric Anomaly')
title('Keplers Equation')
end
this is the code. matlab is not showing any error or any result.
0 个评论
回答(1 个)
Walter Roberson
2023-5-28
Your code defines kepler_plot but never invokes it.
But you have other problems as well. I had to guess what you were doing.
e = 0.1;
M_min = 0;
M_max = 2 * pi;
N = 20;
[E, M] = kepler_plot(e, M_min, M_max, N)
function [E, M] = kepler_plot(e, M_min, M_max, N)
f = @(E,m) E - e * sin(E) - m;
M = linspace(M_min, M_max, N);
E = arrayfun(@(m) fzero(@(E)f(E,m), 0), M);
plot(M, E)
xlabel('Mean Anomaly')
ylabel('Eccentric Anomaly')
title('Keplers Equation')
end
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!