0 1 0 0 0 0 0
isinf(A)
ans =
0 0 1 1 0 0 0
isfinite(A)
ans =
1 0 0 0 1 1 1
7、用结构体矩阵来存储5名学生的基本情况数据,每名学生的数据包括学号、姓名专业和6门课程的成绩。
答:程序设计:
student(1).number=101; student(1).name='wang'; student(1).specialty='computer'; student(1).grad e=[86 85 90 93 97 95];
student(2).number=102; student(2).name='zhang'; student(2).specialty='computer'; student(2).grad e=[87 88 86 90 83 92];
student(3).number=103; student(3).name='zhao'; student(3).specialty='computer'; student(3).grade =[70 68 80 78 92 85];
student(4).number=104; student(4).name='liu'; student(4).specialty='computer'; student(4).grade=[ 88 78 90 82 95 77];
student(5).number=105; student(5).name='duan'; student(5).specialty='computer'; student(5).grade =[87 68 90 80 75 91]; student
student =
1x5 struct array with fields:
number
name
specialty
grade
8、建立单元矩阵B并回答有关问题。
B{1,1}=1;
B{1,2}=’Brenden’;
B{2,1}=reshape(1:9,3,3);
B{2,2}={12,34,34,2;54,21,3;4,23,67};
(1)size(B)和ndims(B)分别是多少?
(2)B(2)和B(4)的值分别是多少?
(3)B(3)=[]和B[3]=[]执行后,B的值分别是多少?
答:
B={1,'Brenden';reshape(1:9,3,3),{12,34,2;54,21,3;4,23,67}}
B=
[ 1] 'Brenden' [3x3 double] {3x3 cell}
size(B)
ans =
2 2
ndims(B)
ans = 2
B(2)