-
大小: 16KB文件類型: .m金幣: 1下載: 2 次發(fā)布日期: 2021-05-29
- 語言: Matlab
- 標(biāo)簽: MATLAB??學(xué)生信息??管理系統(tǒng)??
資源簡介
用MATLAB的m文件編寫的一套學(xué)生信息管理系統(tǒng),有一個不錯的交互界面,可以輕松地輸入、查詢、修改、刪除學(xué)生的各項信息。這個m文件只能在MATLAB中運(yùn)行。
代碼片段和文件信息
%?Call?var(xflagdim)?with?as?many?of?those?args?as?are?present.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%本程序在基本文件操作的基礎(chǔ)上實(shí)現(xiàn)了更強(qiáng)的錯誤處理功能,可以直接對%%%
%文本進(jìn)行操作。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function?std3()
%UNtitleD?Summary?of?this?function?goes?here
%???Detailed?explanation?goes?here
stu=struct(‘id‘{cell(12)}‘math‘{cell(12)}‘Eng‘{cell(12)}‘phy‘{cell(12)}‘a(chǎn)ve‘{cell(12)}‘sum‘[]);
stustr=struct(‘id‘{cell(12)}‘math‘{cell(12)}‘Eng‘{cell(12)}‘phy‘{cell(12)}‘a(chǎn)ve‘{cell(12)}‘sum‘{});
stupai=struct(‘id‘{cell(12)}‘math‘{cell(12)}‘Eng‘{cell(12)}‘phy‘{cell(12)}‘a(chǎn)ve‘{cell(12)}‘sum‘[]);
while?1
fid?=?fopen(‘stud1.txt‘?‘a(chǎn)+‘);???????????
fclose(fid);????
????
fid?=?fopen(‘stud1.txt‘‘r‘);
m5?=?fscanf(fid‘%c‘);
numel(m5);
fclose(fid);
if?numel(m5)==0?
fid?=?fopen(‘stud1.txt‘?‘w‘);???????????
fprintf(fid?‘??????學(xué)號???數(shù)學(xué)(??等級?)???英語(??等級?)???物理(??等級?)???平均分(??等級?)???總分?????????????姓名\n‘);
%新增的等級允許用7個字符格式
fclose(fid);
fid2?=?fopen(‘stud1.txt‘?‘r‘);
m5?=?fscanf(fid2‘%c‘);
fclose(fid2);
end;???
numel(m5);
length=numel(m5)-78;
row=ceil(length/102);
m6=char(linspace(4848row*102+78));??%測試點(diǎn)1
for?n01=1:numel(m5)
m6(n01)=m5(n01);
end
clear?m5;
%?????m6???%測試點(diǎn)
if?row>0
???for?n0=1:row
???????%格式為10+5(9)+8(9)+8(9)+9(11)+8+15+1(回車)=102
???????mao11=(n0-1)*102+78+1;????%?運(yùn)用‘錨’鏈接的思想找到每個單元的起始錨點(diǎn)%學(xué)號
???????stu(n0).id{11}=uint32(str2double(m6(mao11:mao11+9)));???????
???????mao12=(n0-1)*102+78+87;%姓名
???????stu(n0).id{12}=m6(mao12:mao12+14);
???????mao21=mao11+10;%數(shù)學(xué)
???????mao22=mao21+5;
???????stu(n0).math{11}=uint32(str2double(m6(mao21:mao21+4)));
%????????stu(n0).math{12}=m6(mao22:mao22+6);
???????mao31=mao22+9;%英語
???????mao32=mao31+8;
???????stu(n0).Eng{11}=uint32(str2double(m6(mao31:mao31+7)));
%????????stu(n0).Eng{12}=m6(mao32:mao32+6);???????
???????mao41=mao32+9;%物理
%????????mao42=mao41+7;
???????stu(n0).phy{11}=uint32(str2double(m6(mao41:mao41+7)));
%????????stu(n0).phy{12}=m6(mao42:mao42+6);
%????????stu(n0)???%程序測試點(diǎn)2
???????stu(n0)=jisuan(stun0);
???????mysav(stunumel(stu));%保存信息
%?????????stu
???end
%????stu
%????whos?stu;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%以上實(shí)現(xiàn)了從文本中讀取數(shù)據(jù)并進(jìn)行格式轉(zhuǎn)換,再放入結(jié)構(gòu)體變量stu中
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?b=size(stu);
row1=row;
a=input(‘請選擇:|1?查看信息?|2?新增信息??|3?修改信息??|4?刪除信息?|0?退出??:‘);
if?a==1
%查看信息
row2=row;
if?row>0
?c=numel(stu);??%測試點(diǎn)3?
a1=1;
while?a1?~=0
????a1=input(‘查詢?請選擇:|0?返回?|1?按學(xué)號查詢?|2?全部輸出?|3?按總成績排名輸出|4?圖表輸出:‘);
%??????stu????%程序測試點(diǎn)4
????if?numel(a1)==0
????????fprintf(‘輸入錯誤!\n‘);
????????break;
????end
????if?a1==4
????????draws(stu);
????end
????
????if?a1==1
????????a12=input(‘輸入學(xué)號:‘);
????????times=0;??
????????fprintf(‘**************成績查詢結(jié)果--按學(xué)號查詢***********************************************************************\n‘);
????????fprintf(?‘??????學(xué)號???數(shù)學(xué)(??等級?)???英語(??等級?
- 上一篇:一個簡單的自適應(yīng)控制matlab
- 下一篇:求圖像邊緣像素最短距離
評論
共有 條評論