声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2730|回复: 4

[绘图技巧] excel中的日期如何读入matlab并画图

[复制链接]
发表于 2010-11-19 11:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
本帖最后由 goodjack 于 2010-11-19 11:11 编辑

1月2日        2
2月5日        4
2月6日        3
3月23日        5
4月21日        5
5月16日        6
5月18日        3
6月5日        1
6月12日        2
6月16日        7
6月22日        1
7月14日        1
7月18日        1
7月26日        2
8月4日        5
8月6日        3
9月12日        2
9月18日        2
9月28日        1
10月4日        4
10月7日        6
11月2日        5
11月5日        7
11月15日        2
11月18日        3
11月19日        4
12月14日        5
12月21日        1

要求横坐标为月份,纵坐标该月份对应数值的累加

评分

1

查看全部评分

回复
分享到:

使用道具 举报

发表于 2010-11-19 11:32 | 显示全部楼层
1.可以用xlsread读入,日期以字符串读入
  1. [num,txt,raw] = xlsread(filename) reads data from the first worksheet in the Microsoft Excel spreadsheet file named filename and returns the numeric data in array num. Optionally, returns the text fields in cell array txt, and the unprocessed data (numbers and text) in cell array raw.
复制代码
2.设置坐标轴的xticklabel属性
3.如果很多的话,可以旋转xticklabel
http://www.mathworks.com/matlabc ... 86-xticklabelrotate

评分

1

查看全部评分

发表于 2010-11-19 12:50 | 显示全部楼层
2用datetick即可解决!
3用cumsum函数!
查看一下help就会使用了!

评分

1

查看全部评分

 楼主| 发表于 2010-11-20 08:53 | 显示全部楼层
cumsum是对列求和,但是我这里所有数据都在同一列
我要求的是比如7月份,那应该是
7月14日        1
7月18日        1
7月26日        2
这三组数据相加啊
发表于 2010-11-20 14:52 | 显示全部楼层
你可以按照这个数组的第一列的第一个字符将月份分开存储,然后用cumsum即可!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-18 13:54 , Processed in 0.064800 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表