㈠ 如何用matlab构建一个债券价格时间序列数据
比如,时间(秒)从1到9999,储存在a(...)里面。 for i=1:9999 B(i)=length(find(a==i)) end plot(B) 横坐标是时间(秒)从1-9999 纵坐标时每一个秒下的采样点个数。
㈡ matlab里面根据日期求加权平均收益
%将数据集导入matlab,命名为AA
r1=0;%收益
a2=sum(AA(:,5));%所有公司总资产
for ii=1:length(AA(:,5))
r1=r1+(AA(ii,5)/a2)*AA(ii,3);
end
r1%这就是你要的收益
㈢ matlab中如何读取带有日期和时间的txt数据文件,并放入矩阵中
假定data_zd.txt文件内容为:
2018-01-16 00:00:00 -290.27 -201.9 421.1 999999 13.22
2018-01-16 00:00:01 -290.26 -201.9 421.1 999999 13.22
2018-01-16 00:00:02 -290.25 -201.9 421.2 999999 13.22
2018-01-16 00:00:03 -290.26 -201.9 421.1 999999 13.22
代码:
FileName='data_zd.txt'; %文件名
[y,m,d,hh,mm,ss,d1,d2,d3,d4,d5]=textread(FileName,'%d-%d-%d %d:%d:%d %f %f %f %f %f');
T=datenum(y,m,d,hh,mm,ss); %转成时间序列
subplot(2,2,1); plot(T,d1); datetick('x','SS');
subplot(2,2,2); plot(T,d2); datetick('x','SS');
subplot(2,2,3); plot(T,d3); datetick('x','SS');
subplot(2,2,4); plot(T,d5); datetick('x','SS');
初步估计是地震观测数据,如果文件长度较大,你自己改一下datetick里面的SS,换成小时就是HH
㈣ 债券本金应付的指定日期被称为以下哪一个日期
债券基金不错的,要问问
㈤ MATLAB如何获取和转换日期/时间
不知道你要怎么转换。matlab 里有 datetime 这个数据类型,用来处理时间的。这个数据类型从 2014b 开始引入,极大的增强了 matlab 对时间和日期的处理能力。
不带参数调用 datetime,就是获取当前的时间和日期,比如
>>d=datetime()
d=
datetime
28-Aug-201817:57:11
㈥ matlab 如何将日期格式写成yyyymmddhhmmss形式
MATLAB中将日期时间转换为字符串的函数是datestr,但并不支持你的这种格式。
比较接近的是格式30(ISO 8601),不过多了一个字符“T”,可以给替换掉:
>>year=2012;month=1;day=1;hour=3;min=6;sec=1;
>>strrep(datestr(datenum(year,month,day,hour,min,sec),30),'T','')
ans=
20120101030601
当然,也可以直接用sprintf函数来写:
>>sprintf('%i%02i%02i%02i%02i%02i',year,month,day,hour,min,sec)
ans=
20120101030601
㈦ matlab如何读取日期变量
最基本的tic,toc
tstart = tic;
elapsed = toc(tstart); %计算的是从tstart开始到toc的时间间隔
运行结果示例:
tstart = tic
tstart =
373853070750740
elapsed = toc(tstart)
elapsed =
81.1367
2、时间变量以及文件读取
help textscan
TEXTSCAN Read formatted data from text file or string.
C = TEXTSCAN(FID,'FORMAT') reads data from an open text file identified
by FID into cell array C. Use FOPEN to open the file and obtain FID.
The FORMAT is a string of conversion specifiers enclosed in single
quotation marks. The number of specifiers determines the number of
cells in the cell array C. For more information, see "Format Options."
C = TEXTSCAN(FID,'FORMAT',N) reads data from the file, using the FORMAT
N times, where N is a positive integer. To read additional data from
the file after N cycles, call TEXTSCAN again using the original FID.
C = TEXTSCAN(FID,'FORMAT','PARAM',VALUE) accepts one or more
comma-separated parameter name/value pairs. For a list of parameters
and values, see "Parameter Options."
C = TEXTSCAN(FID,'FORMAT',N,'PARAM',VALUE) reads data from the
file, using the FORMAT N times, and using settings specified by pairs
of PARAM/VALUE arguments.
C = TEXTSCAN(STR,...) reads data from string STR. You can use the
FORMAT, N, and PARAM/VALUE arguments described above with this syntax.
However, for strings, repeated calls to TEXTSCAN restart the scan from
the beginning each time. (To restart a scan from the last position,
request a POSITION output. See also Example 3.)
[C, POSITION] = TEXTSCAN(...) returns the file or string position at
the end of the scan as the second output argument. For a file, this is
the value that FTELL(FID) would return after calling TEXTSCAN. For a
string, POSITION indicates how many characters TEXTSCAN read.
Notes:
When TEXTSCAN reads a specified file or string, it attempts to match
the data to the format string. If TEXTSCAN fails to convert a data
field, it stops reading and returns all fields read before the failure.
Format Options:
The FORMAT string is of the form: %<WIDTH>.<PREC><SPECIFIER>
<SPECIFIER> is required; <WIDTH> and <PREC> are optional.
<WIDTH> is the number of characters or digits to read.
<PREC> applies only to the family of %f specifiers, and specifies
the number of digits to read to the right of the decimal point.
Supported values for SPECIFIER:
Numeric Input Type Specifier Output Class
------------------ --------- ------------
Integer, signed %d int32
%d8 int8
%d16 int16
%d32 int32
%d64 int64
Integer, unsigned %u uint32
%u8 uint8
%u16 uint16
%u32 uint32
%u64 uint64
Floating-point number %f double
%f32 single
%f64 double
%n double
TEXTSCAN converts numeric fields to the specified output type
according to MATLAB rules regarding overflow, truncation, and the
use of NaN, Inf, and -Inf. For example, MATLAB represents an
integer NaN as zero.
TEXTSCAN imports any complex number as a whole into a complex
numeric field, converting the real and imaginary parts to the
specified type (such as %d or %f). Do not include embedded white
space in a complex number.
Character Strings Specifier Details
----------------- --------- -------------------------
㈧ 债券的一些英文日期问题= =
因为债券是可以在二级市场交易的,交易日可以出现在债券有效期内的任何时候(不止是债券发行日或发放票息的日子),这个日子被称为settlement date。在计算债券交易的Full price的时候会用到
㈨ matlab里 日期的遍历
StartDate=datenum(2014,1,8,1,30,0);
EndDate =datenum(2014,2,8,1,30,0);
Dt=0.5/24; %换成天
Date=datestr(StartDate:Dt:EndDate,'yyyy-mm-dd HH:MM:SS')
㈩ Matlab中的日期命令now
now; %获取当前时间至0000年的天数