% xrand=round(rand(3,7)*32); indexes=find(xrand==20); length(indexes) % xrand=round(rand(3,7)*32); sum20=sum(xrand(:)==20); disp(sum20) % count=0; for i=1:3 for j=1:7 if xrand(i,j) == 20 count=count+1 end end end count=0; for i=1:3 for j=1:7 switch xrand(i,j) case 20 count=count+1; end end end gender=[1 2 1] grade=[1 2 3] score=[80 70 95] mentalhealth=zeros(300,3) mentalhealth(:,1)=gender mentalhealth(:,2)=grade mentalhealth(:,3)=score mentalhealthNew=sortrows(mentalhealth,[-1 2]); disp(mentalhealthNew) MyInfo.name='Huang Xiangwen'; MyInfo.gender='male'; MyInfo.age=20; MyInfo.hometown='Yichang'; MyInfo.hobby='chess' OurInfo=struct('name',{'Huang Xiangwen','Wu Jieying','Wu Haiyan','Liang Xiaoqing'},'gender',{'male','male','female','female'},'age',{18 19 19 19},'hometown',{'Yichang','guangdong','ChengHai','MaoMing'},'hobby',{'chess','Playing guita','sleeping','sleeping'}) owngroup=struct('name',{'ZouYiZi','ChenJiaHuan','WangZiYu','ZhangYingDan'},'gender',{'female','male','male','female'},'age',{18,19,19,19},'hometown',{'Hunan','MaoMing','ChengHai','MaoMing'},'hobby',{'Sleeping','Playing guita','sleeping','sleeping'}); othergroup=struct('name',{'QiuYanMing','LuXiaoQiao','SuiYi','HuWei'},'gender',{1,2,1,2},'age',{20,19,19,19},'hometown',{'GuangdongMaoming','Guangdong','Jilin','Guangdong'},'hobby',{'singing','talking with other','listening music','none'}); ClassInfo=struct('owngroup',owngroup,'othergroup',othergroup) mean([ClassInfo.owngroup.age ClassInfo.othergroup.age]) std([ClassInfo.owngroup.age,ClassInfo.othergroup.age],1) line.width=5;line.style='-.'; line.color='r'; line.markershape='+'; line.markersize=10; line.markerfacecolor=[0.7 0.6 0.4]; line.markeredgecolor=[0 1 0.5]; close all x=0:8:100; y=300-3*x+4; p=plot(x,y); set(p, 'Color', line.color,'LineStyle', line.style,'LineWidth', line.width,'Marker', line.markershape,'MarkerSize', line.markersize,'MarkerEdgeColor' , line.markeredgecolor, 'MarkerFaceColor', line.markerfacecolor); MyPsyCourse={'Mental Health Education for college students','Psychology History','General Psychology','Personality Psychology','Experimental Psychology','Social Psychology','Statistics of Psychology and Application of SPSS','Psychology experiment software application'}; disp(MyPsyCourse(7)) raw_score=112; stand_score=CollegeIQ(raw_score);