フィルターのクリア

import and plot dated time series

15 ビュー (過去 30 日間)
tilfani oussama
tilfani oussama 2018 年 2 月 12 日
コメント済み: Ganesh 2023 年 10 月 21 日
Hello I have an excel files containing financial time series, two columns the first indicate the date and the second indicates values, i would like to import this file from excel to matlab and ploting a graph with date in "x " axis and in the "y" axis the values. Tnak you
  2 件のコメント
Akira Agata
Akira Agata 2018 年 2 月 13 日
Seems that using readtable and plot functions (and maybe datetime function), you can plot it. If possible, I would like to suggest sharing your sample Excel file here.
Ganesh
Ganesh 2023 年 10 月 21 日
1

サインインしてコメントする。

採用された回答

tilfani oussama
tilfani oussama 2018 年 2 月 13 日
This my series to plot: SP returns

その他の回答 (2 件)

Peter Perkins
Peter Perkins 2018 年 2 月 13 日
As Akira says, use readtable and plot. In recent versions, readtable will create a datetime variable automatically, in earlier versions you may need to convert from text to datetime. In R2016b or later, convert the table to a timetable. You have one time variable and two data series, so there are various ways you might want to make a plot. Using ttplot from the File Exchange, this:
>> t = readtable('SP index.xls');
>> tt = table2timetable(t);
>> ttplot(tt)
gives me this:
  2 件のコメント
tilfani oussama
tilfani oussama 2018 年 2 月 13 日
i worte this code i get error "undefined function or variable "table2timetable". I notice that i have Matlab R2015a Thank you
Peter Perkins
Peter Perkins 2018 年 2 月 13 日
You need R2016b or later to use timetables. But "However, ttplot also works with a table that contains a datetime or duration variable, and so is also useful for R2014b-R2016a."

サインインしてコメントする。


Viktor Bolgov
Viktor Bolgov 2019 年 10 月 25 日
編集済み: Viktor Bolgov 2019 年 10 月 25 日
Hello!
I have a similar problem. I try to read my measurement file recorded in the format Date Time Current: 03.06.2017 03:15:45:878301 643.1426. The file with the data is attached. I tried to apply the mentioned above commands.
>> t = readtable('01.xls');
>> tt = table2timetable(t);
>> ttplot(tt)
The execution of the first command gave me table 330x2 in the next form.
Column1 Column2
____________________________ __________
'03.06.2017 03:15:45:878301' '643.1426'
'03.06.2017 03:15:45:888320' '643.1418'
'03.06.2017 03:15:45:898340' '643.1401'
The attemt to apply command table2timetable(t) gave the next mistake.
Error using table2timetable (line 58)
Input table must contain datetime or duration vector for row times.
Any help, please. I am using Matlab 2018b.
  2 件のコメント
Akira Agata
Akira Agata 2019 年 10 月 28 日
Before plotting it, you need to convert each column to appropriate variable type. The following is an example:
t = readtable('01.xls');
% Convert Column1 to datetime, and Column2 to double
t.Column1 = datetime(t.Column1,'InputFormat','dd.MM.yyyy hh:mm:ss:SSS');
t.Column2 = str2double(t.Column2);
tt = table2timetable(t);
plot(tt.Column1,tt.Column2)
Viktor Bolgov
Viktor Bolgov 2019 年 11 月 27 日
Dear Mr. Akira Agita!
Your advice helped me! It works! Thank you very much for your kind cooperation.
Yours sincerely,
Viktor Bolgov

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by