Potential subjects for an experiment that are stored in a vector:
1 次查看(过去 30 天)
显示 更早的评论
>> subjects subjects = 1x3 struct array with fields: name sub_id height weight >> subjects(1) ans = name: 'Joey' sub_id: 111 height: 6.7000 weight: 222.2000
As an example, you can create the following vector of subjects in your command window: subjects(4) = struct('name','Mary','sub_id',363,'height',5.1,'weight',110); subjects(1) = struct('name','Joey','sub_id',111,'height',6.7,'weight',222.2); subjects(2) = struct('name','Pat','sub_id',221,'height',5.9,'weight',165); subjects(3) = struct('name','John','sub_id',201,'height',5.2,'weight',155);
For this particular experiment, the only subjects who are eligible are those whose height or weight is lower than the average height or weight of all subjects. Write a function that takes this vector as input argument. The function will examine all records and print the names of those who are eligible. Don’t assume that the length of the vector is known; the code should be general.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!