


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、請先下載本週上課資料 點選左欄課程資料à 圖形使用者介面 下載第4週上課資料materials L4.zip,檔案大小約6.4MB 請先將Current Directory切換至materials_L4資料夾!CF結構矩陣與異值矩陣盧家鋒 助理教授.twCF10/9/2014 Lesson 4, ChiaFeng Lu110/9/2014 Lesson 4, ChiaFeng Lu2本週內容 異質矩陣 (cell array) 結構矩陣 (structure array)What can we store in an array? A=1:2:30; A
2、(9) A='Alvin' 'Lu' % Does it work? A='Alvin' 'Lu ' % Does it work? A='This is a test!' A(9)R2013b Can we store numbers and strings in an array? A=25000 'This is a test!' % Does it work? A=25000; 'This is a test!' % Does it work?CFCF10/9/2014 Le
3、sson 4, ChiaFeng Lu310/9/2014 Lesson 4, ChiaFeng Lu4Strings in an array List = 'David ' 'Andy% List =' 'Jay' 'Jolin ' 'Selina'DavidAndy Jay JolinSelinaCF異質矩陣cell arrayCF10/9/2014 Lesson 4, ChiaFeng Lu6Archive Big DatasetFor example, 30 normal controls vs. 30 p
4、atients with strokeCell Array Store different data formats in a single cell array. Numbers, strings, arrays Name, ID Age, gender, height, weight Pre-training data (8 x 450 values) Post-training data (8 x 450 values)à stringà numbersà number arrayà number array試試看在command window中鍵
5、入load('ExampleCell.mat')CFCF10/9/2014 Lesson 4, ChiaFeng Lu710/9/2014 Lesson 4, ChiaFeng Lu8c1c2c3c4c5c6r1Davidr2Andyr3Jayr4Jolinr5SelinaCreate a Cell array data= ; data=cell(4,1);Create a Cell array Different Ways data=cell(4,1);data(1)='NC01'data(2)=62; data(3)=rand(8,450);data(4)=
6、 16, '%task onset' data=cell(4,1); data1='NC01' data2=62; data3=rand(8,450); data4= 16, '%task onset'% string% number% number array% cell array data(1)='NC01' data(2)=62; data(3)=rand(8,450); data(4)= 16, '%task onset'% string% number% number array% cell array
7、% string% number% number array% cell array10/9/2014 Lesson 4, ChiaFeng LuCFCFUse variable viewer to check the data structure!10/9/2014 Lesson 4, ChiaFeng Lu910More Intuitive WayWhen dealing with different length of strings List = 'David ' 'Andy ' 'Jay ' 'Jolin ' '
8、Selina'Index of a cell array List = 'David' 'Andy' 'Jay' 'Jolin' 'Selina' Is there any difference between following two commands? List(1) List1à cell arrayà string List = 'David' 'Andy' 'Jay' 'Jolin' 'Selina
9、9;CFCF10/9/2014 Lesson 4, ChiaFeng Lu1110/9/2014 Lesson 4, ChiaFeng Lu12Useful Functions cell Create cell array iscell True for cell arrayIndex of a cell array A=rand(6,4),rand(5,7); Try it iscell(List(1) iscell(List1)A1,2(4,5)Navigation in variable viewer10/9/2014 Lesson 4, ChiaFeng LuCFCF10/9/2014
10、 Lesson 4, ChiaFeng Lu1314Index & Matrix OperationsConcatenation of Cell Arrays The same rule as usual.BAA1,1(2:4,2:3)+A1,2(2:4,5:6)A1,1(2:4,2:3)-A1,2(2:4,5:6)A1,1(2:4,2:3).*A1,2(2:4,5:6)A1,1(2:4,2:3)./A1,2(2:4,5:6)CFCF10/9/2014 Lesson 4, ChiaFeng Lu1510/9/2014 Lesson 4, ChiaFeng Lu16Archive Big
11、 DatasetFor example, 30 normal controls vs. 30 patients with stroke Name, ID Age, gender, height, weight Pre-training data (8 x 450 values) Post-training data (8 x 450 values)à stringà numbersà number arrayà number arrayCF結構矩陣structure array試試看在command window中鍵入load('ExampleS
12、truct.mat')CF10/9/2014 Lesson 4, ChiaFeng Lu1710/9/2014 Lesson 4, ChiaFeng Lu18Structure Array Store different data formats in a single structure array. Numbers, strings, arraysCell vs. Structure ArrayCFCF10/9/2014 Lesson 4, ChiaFeng Lu1910/9/2014 Lesson 4, ChiaFeng Lu20Structure of a Structure
13、ArrayCreate a Structure array ='NC01' data.age=62; data.predata=rand(8,450); data.notation= 16, '%task onset'% string% number% number array% cell arraydataa 1x3 structure arraysubject1subject2subject3name age, genderheight weight dataname age, genderheight weight dataname ag
14、e, genderheight weight data6 Fields for each subjectCFUse variable viewer to check the data structure! CF10/9/2014 Lesson 4, ChiaFeng Lu22Create a Structure array data(1).name='NC01'data(1).age=62; data(1).predata=rand(8,450); data(1).notation= 16, '%task onset' data(2).name='NC0
15、2' data(2).age=54;data(2).predata=rand(8,450);More Intuitive WayWhen dealing with different length of strings% string% number% number array% cell array% string% number% number array List = 'David ' 'Andy ' 'Jay' 'Jolin ' 'Selina' List(1).name = 'David&
16、#39; List(2).name = 'Andy' List(3).name = 'Jay' List(4).name = 'Jolin' List(5).name = 'Selina'data(2).notation= 23, '%task onset'% cell arrayUse variable viewer to check the data structure! CFCF10/9/2014 Lesson 4, ChiaFeng Lu2310/9/2014 Lesson 4, ChiaFeng Lu24
17、Index of a struct array Use both index and field name to specify data location.Index & Matrix Operationsdata(1).predate(2:5,3:4)+data(2).predate(4:7,4:5)data(1).predate(2:5,3:4)-data(2).predate(4:7,4:5)data(1).predate(2:5,3:4).*data(2).predate(4:7,4:5)CFdata(1).predate(2:5,3:4)./data(2).predate(
18、4C:7,4F:5)data(1).predate(6,3)Navigation in variable viewer10/9/2014 Lesson 4, ChiaFeng Lu2510/9/2014 Lesson 4, ChiaFeng Lu26Useful FunctionsBenefits for Using a Single Array Easy to clear, save, and loadstruct Create or convert to structure array S = struct('field1',VALUES1,'field2',VALUES2,.)isstruct True for structuresfields Display a list of fields in a structure arrayisfield True if field is in structure arrayrmfield Remove fields from a structure array10/9/2014 Lesson 4, ChiaFeng Lu Easy to make it a global variable global data global
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 战略合作的寻求与维护计划
- 城市交通可持续发展规划师重点基础知识点
- 法学概论知识点学习中的难点与突破试题及答案
- 2024年山东财经大学辅导员考试真题
- 2024年湖北省医疗保障局下属事业单位真题
- 陕西省山阳县2025届七年级数学第二学期期末统考试题含解析
- 2024年海南省外事办公室下属事业单位真题
- 2024年贵州省应急管理厅下属事业单位真题
- 2024年安徽省生态环境厅下属事业单位真题
- 2024年防城港市园林管理处招聘笔试真题
- 收养孩子回访报告范文
- 2025年高二物理学考重点知识点公式归纳总结(复习必背)
- 梦中的婚礼钢琴简谱曲谱
- 文化产品创意与策划-终结性考核-国开(SC)-参考资料
- 《骆驼祥子》中“虎妞”形象分析6200字(论文)
- 《质量管理体系国家注册审核员预备知识培训教程》
- 2024年5月26日河南省事业单位联考《公共基础知识》试题
- 儿歌大全100首歌词
- 粮油食材配送投标方案(大米食用油食材配送服务投标方案)(技术方案)
- 个人独资企业(合伙企业)转型有限责任公司登记申请书
- 2023年湖南省普通高等学校对口招生考试机电类专业综合知识试题附答题卡
评论
0/150
提交评论