Cell contents reference from a non-cell array object table2array

2 visualizaciones (últimos 30 días)
Hannah Joyce
Hannah Joyce el 6 de Jul. de 2018
Comentada: Hannah Joyce el 6 de Jul. de 2018
% import data and convert into an array
a = open('dst1993.mat');
x = table2array(a.Dst_val);
b = open('ae1993.mat');
x2 = table2array(b.AE_val);
gets me error:
Cell contents reference from a non-cell array object.
Error in table2array (line 27)
a = t{:,:};
Error in dstvsae (line 11)
x = table2array(a.Dst_val);
I'm really bad at coding but I need to get this done :/
  6 comentarios
Paolo
Paolo el 6 de Jul. de 2018
Editada: Paolo el 6 de Jul. de 2018
Those are serial date numbers. Read more about it here.
What is the desired output for your dates? Try:
a = load('dst1993.mat');
dates = datetime(a.Dst_val(1:720),'ConvertFrom','datenum')';
values = a.Dst_val(721:end)';
T = table(dates,values)
T is a now a Table containing variables dates and values. Then simply plot your data:
plot(T.dates,T.values);
Hannah Joyce
Hannah Joyce el 6 de Jul. de 2018
so if I wanted to plot this data set on the same time axis (time is column one, columns 2, 3 and 4 are different data sets) I'd just copy that and edit it to be ae1993.mat and AE_val instead of Dst?
or would it be a bit more complicated as there are 3 columns of different data?

Iniciar sesión para comentar.

Respuestas (2)

Jan
Jan el 6 de Jul. de 2018
Start with:
Data = load('dst1993.mat')
What do you get for:
class(Data.Dst_val)
? If you know this, the conversion to an array should be easy.
  1 comentario
Hannah Joyce
Hannah Joyce el 6 de Jul. de 2018
Undefined variable "Data" or class "Data.Dst_val".
Error in dstvsae (line 10)
class(Data.Dst_val)

Iniciar sesión para comentar.


Peter Perkins
Peter Perkins el 6 de Jul. de 2018
In a recent-ish version of MATLAB, try this:
>> load('ae1993.mat')
>> t = array2table(AE_val,'VariableNames',{'Time' 'X' 'Y' 'Z' 'W'});
>> t.Time = datetime(t.Time,'ConvertFrom','datenum');
>> tt = table2timetable(t);
>> head(tt)
ans =
8×4 timetable
Time X Y Z W
____________________ __ __ ___ __
01-Sep-1993 00:00:00 35 28 -6 10
01-Sep-1993 01:00:00 36 26 -9 8
01-Sep-1993 02:00:00 80 49 -30 8
01-Sep-1993 03:00:00 50 40 -9 15
01-Sep-1993 04:00:00 47 37 -9 13
01-Sep-1993 05:00:00 36 23 -13 4
01-Sep-1993 06:00:00 44 27 -16 4
01-Sep-1993 07:00:00 48 32 -16 7
>> plot(tt.Time,tt.Variables)
That's kind of pretty.
  1 comentario
Hannah Joyce
Hannah Joyce el 6 de Jul. de 2018
thank you :)
its the auroral electrojet data in the ionosphere from september 1993

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by