㈠ 如何用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年的天數