1090 0

[Weka及其他] MATLAB课程:代码示例之Working with Arrays and Matrices(三) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.4857
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399143 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-7 11:58:22 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Working with Arrays and Matrices(三)

Create a Structure Array


This example shows how to create a structure array. A structure is a data type that groups related data using data containers called fields. Each field can contain data of any type or size.


Store a patient record in a scalar structure with fields name, billing, and test.


patient(1).name = 'John Doe';patient(1).billing = 127.00;patient(1).test = [79, 75, 73; 180, 178, 177.5; 220, 210, 205];patient


patient =        name: 'John Doe'    billing: 127       test: [3x3 double]


Add records for other patients to the array by including subscripts after the array name.


patient(2).name = 'Ann Lane';patient(2).billing = 28.50;patient(2).test = [68, 70, 68; 118, 118, 119; 172, 170, 169];patient


patient = 1x2 struct array with fields:    name    billing    test


Each patient record in the array is a structure of class struct. An array of structures is often referred to as a struct array. Like other MATLAB arrays, a struct array can have any dimensions.

A struct array has the following properties:

  • All structs in the array have the same number of fields.

  • All structs have the same field names.

  • Fields of the same name in different structs can contain different types or sizes of data.


Any unspecified fields for new structs in the array contain empty arrays.

patient(3).name = 'New Name';patient(3)


ans =        name: 'New Name'    billing: []       test: []


Access data in the structure array to find how much the first patient owes, and to create a bar graph of his test results.

amount_due = patient(1).billingbar(patient(1).test)title(['Test Results for ', patient(1).name])


amount_due =   127




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Matrices MATLAB课程 matrice working matric MATLAB课程 代码示例 WorkingwithArraysandMatrices(三) CreateaStructureArray


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-24 22:19