台大郭彦甫04笔记 | 变数与档案存取(part one)

string

字串儿

structures

用来储存异值数据

img

1. student.name = 'John Doe'; 
2. student.id = 'jdo2@sfu.ca';
3. student.number = 301073268; 
4. student.grade = [100, 75, 73; ...
5. 95, 91, 85.5; ...
6. 100, 98, 72];
7. student

增加信息

img

1. A = struct('data', [3 4 7; 8 0 1], 'nest', ...
2. struct('testnum'
3. , 'Test 1', ...
4. 'xdata', [4 2 8],'ydata', [7 1 6])); 
5. A(2).data = [9 3 2; 7 6 5]; 
6. A(2).nest.testnum = 'Test 2'; 
7. A(2).nest.xdata = [3 4 2]; 
8. A(2).nest.ydata = [5 0 9];
9. A.nest

img


nesting struct 嵌入的struct

img

 A = struct('data', [3 4 7; 8 0 1], 'nest', ...
struct('testnum'
, 'Test 1', ...
'xdata', [4 2 8],'ydata', [7 1 6])); 
A(2).data = [9 3 2; 7 6 5]; 
A(2).nest.testnum = 'Test 2'; 
A(2).nest.xdata = [3 4 2]; 
A(2).nest.ydata = [5 0 9];
A.nest

cell

看作pointer

img

A(1,1)={[1 4 3; 0 5 8; 7 2 9]};
A(1,2)={'Anne Smith'};
A(2,1)={3+7i};
A(2,2)={-pi:pi:pi};
A
A{1,1}=[1 4 3; 0 5 8; 7 2 9];
A{1,2}='Anne Smith';
A{2,1}=3+7i;
A{2,2}=-pi:pi:pi; A

你好,同学,请问你需要问什么样的问题呢,还是只是说梳理一下结构体的知识