I would like to know the format for the "Decimal Year" input in the World Magnetic Model 2000 Block in the Aerospace Blockset 1.6.2 (R14SP2)?

1 view (last 30 days)
I would like to dynamically update the date for the World Magnetic Model 2000 Block. I have checked the "Input decimal year" box in the mask, but I am not sure what the format for the incoming signal should be.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
We have verified that documentation on the "Decimal Year" input of the World Magnetic Model 2000 block is not entirely clear.
Here is some additional information on the format of the "Decimal Year" input: the input to the block should be the desired year in a decimal format to include any fraction of the year that has already passed. So the value is the current year plus the number of days that have passed in this year divided by 365.
The following code illustrates how to calculate the decimal year, "dyear", for March 21, 2005:
year = '2005';
year_selected = str2num(year);
month = 'March';
day = '21';
if (mod(year_selected,400)&&~mod(year_selected,100))
% leapyear = false;
ndays = 365;
elseif ~mod(year_selected,4)
% leapyear = true;
ndays = 366;
else
% leapyear = false;
ndays = 365;
end
day_of_year = datenum([day '-' month '-' year])-datenum(['1-january-' year]);
dyear = year_selected + day_of_year/ndays;

More Answers (0)

Categories

Find more on Environment in Help Center and File Exchange

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!