Cell contents reference from a non-cell array object table2array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaires
Paolo
le 6 Juil 2018
Modifié(e) : Paolo
le 6 Juil 2018
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);
Réponses (2)
Jan
le 6 Juil 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.
Peter Perkins
le 6 Juil 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.
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!