MATLAB: plotting data from struct

做~自己de王妃 提交于 2020-03-06 05:47:48

问题


I have a structure of data that contains data values, time, unit, and some descriptions of each data. I want to plot the data values vs time. Here is how the data looks like:

Any ideas how i can plot the data and time?


回答1:


Quick example:

%# date strings and values
dates = {'02.11.2012 00:02:15'; '02.11.2012 00:07:12'};
values = [5.8; 5.7];

%# convert to serial date numbers
t = datenum(dates, 'mm.dd.yyyy HH:MM:SS');

%# plot and format x-ticks as datetime
plot(t,values)
datetick('x')



回答2:


You Need not open the entire readings and then plot the Graphs of those. Instead you can directly Access the strucure and plot the graph by this command :

  • plot(data.(data.arrayOfTimestamp),data.arrayOfValue)


来源:https://stackoverflow.com/questions/15851793/matlab-plotting-data-from-struct

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!