Run a code for 100 years
    9 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Adam Kelly
 le 11 Avr 2020
  
    
    
    
    
    Réponse apportée : Les Beckham
      
 le 11 Avr 2020
            I have a program that I need to run for 100 years, the program is calculating the angle of a circular orbit at 451 days. I want to calculate the angle changing over 100 years, I have the angle calculated for 451 days just want to repeat the same process but add 451 to the last calculation. T=451 days my idea was to have a for loop for the 100 years starting at T=451 days for the first year and then adding 451 to T for each year till 100. 
clear all;
clc;
ro=1.49e11;             %Sun orbital radius (1 AU)            
G=6.67408e-11;
MS=2e+30;
%synodic period
perp = 365;             %planet period (days)
perd = 1896.59;         %red dwarf period (days)
np = 2*pi / perp;       % mean motion of planet (rad/day)
nd = 2*pi / perd;       % mean motion of red dwarf (rad/day)
T = 2*pi / (np - nd)    %This is the average time between stellar eclipses.
v=sqrt((G*MS)/ro);
theta=((v*T)*86400)/ro  %Angle in radians 
0 commentaires
Réponse acceptée
  Les Beckham
      
 le 11 Avr 2020
        I don't think the results are going to be very interesting but you could do what you are asking as follows:
ro=1.49e11;             %Sun orbital radius (1 AU)            
G=6.67408e-11;
MS=2e+30;
%synodic period
perp = 365;             % planet period (days)
perd = 1896.59;         % red dwarf period (days)
np = 2*pi / perp;       % mean motion of planet (rad/day)
nd = 2*pi / perd;       % mean motion of red dwarf (rad/day)
dT = 2*pi / (np - nd);  % This is the average time between stellar eclipses.
v=sqrt((G*MS)/ro);
T = dT:dT:dT*ceil(100*perp/dT); % up to next multiple of dT after 100 years (multiples of perp)
theta=((v*T)*86400)/ro  % Angle in radians at each multiple of dT
This is just going to add a constant increment to theta every dT.  If you plot(T, theta) you will get a boring straight line.  You could, of course, apply a mod by 2*pi but this won't be much more useful (IMHO).
Anyway, I hope this answers your question.  If not, please clarify.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

