Borrar filtros
Borrar filtros

import and plot dated time series

15 visualizaciones (últimos 30 días)
tilfani oussama
tilfani oussama el 12 de Feb. de 2018
Comentada: Ganesh el 21 de Oct. de 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 comentarios
Akira Agata
Akira Agata el 13 de Feb. de 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 el 21 de Oct. de 2023
1

Iniciar sesión para comentar.

Respuesta aceptada

tilfani oussama
tilfani oussama el 13 de Feb. de 2018
This my series to plot: SP returns

Más respuestas (2)

Peter Perkins
Peter Perkins el 13 de Feb. de 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 comentarios
tilfani oussama
tilfani oussama el 13 de Feb. de 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 el 13 de Feb. de 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."

Iniciar sesión para comentar.


Viktor Bolgov
Viktor Bolgov el 25 de Oct. de 2019
Editada: Viktor Bolgov el 25 de Oct. de 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 comentarios
Akira Agata
Akira Agata el 28 de Oct. de 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 el 27 de Nov. de 2019
Dear Mr. Akira Agita!
Your advice helped me! It works! Thank you very much for your kind cooperation.
Yours sincerely,
Viktor Bolgov

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by