필터 지우기
필터 지우기

Code not showing any result or any error

조회 수: 1 (최근 30일)
Tushar Das
Tushar Das 2023년 5월 28일
답변: Walter Roberson 2023년 5월 28일
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.

답변 (1개)

Walter Roberson
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)
E = 1×20
0 0.3665 0.7279 1.0803 1.4217 1.7518 2.0719 2.3836 2.6893 2.9912 3.2920 3.5939 3.8996 4.2113 4.5313 4.8615 5.2029 5.5553 5.9167 6.2832
M = 1×20
0 0.3307 0.6614 0.9921 1.3228 1.6535 1.9842 2.3149 2.6456 2.9762 3.3069 3.6376 3.9683 4.2990 4.6297 4.9604 5.2911 5.6218 5.9525 6.2832
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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by