www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CreateSequenceOfDatetimeOrDurationValuesBetweenEndpointsExample.m
%% Specify Length and Endpoints of Date or Duration Sequence % This example shows how to use the |linspace| function to create equally spaced datetime or duration % values between two specified endpoints. %% % Create a sequence of five equally spaced dates between April 14, 2014 and % August 4, 2014. First, define the endpoints. % Copyright 2015 The MathWorks, Inc. A = datetime(2014,04,14); B = datetime(2014,08,04); %% % The third input to |linspace| specifies the number of linearly spaced % points to generate between the endpoints. C = linspace(A,B,5) %% % Create a sequence of six equally spaced durations between 1 and % 5.5 hours. A = duration(1,0,0); B = duration(5,30,0); C = linspace(A,B,6)