Effacer les filtres
Effacer les filtres

import and plot dated time series

15 vues (au cours des 30 derniers jours)
tilfani oussama
tilfani oussama le 12 Fév 2018
Commenté : Ganesh le 21 Oct 2023
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 commentaires
Akira Agata
Akira Agata le 13 Fév 2018
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 le 21 Oct 2023
1

Connectez-vous pour commenter.

Réponse acceptée

tilfani oussama
tilfani oussama le 13 Fév 2018
This my series to plot: SP returns

Plus de réponses (2)

Peter Perkins
Peter Perkins le 13 Fév 2018
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 commentaires
tilfani oussama
tilfani oussama le 13 Fév 2018
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 le 13 Fév 2018
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."

Connectez-vous pour commenter.


Viktor Bolgov
Viktor Bolgov le 25 Oct 2019
Modifié(e) : Viktor Bolgov le 25 Oct 2019
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 commentaires
Akira Agata
Akira Agata le 28 Oct 2019
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 le 27 Nov 2019
Dear Mr. Akira Agita!
Your advice helped me! It works! Thank you very much for your kind cooperation.
Yours sincerely,
Viktor Bolgov

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by