完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
比如以下脚本:
function mycalculus mynumber=1; global C; screen=get(0,'ScreenSize'); w=screen(3);h=screen(4); tP=0;kP=0;deltay=0;deltar=0;c=3; fh = figure('Position',[0.1*w 0.1*h 0.8*w 0.8*h],'menubar','none','NumberTitle','off',... %创建一个操作界面 'name','科学计算','Units','Normalized'); uicontrol(fh,'style','text','position',[0.3*w 0.1*h 100 30],'string','数据输入',... 'fontsize',15); fset=uicontrol(fh,'style','edit','position',[0.3*w 0.05*h 100 35],...%创建在编辑框中输入c0的edit 'fontsize',13,'callback',@fsetc1); function fsetc1(hObject, eventdata, handles)%对在编辑框中输入c0的响应 C(1,mynumber)=str2double(get(hObject,'String')); mynumber=mynumber+1; set(fset,'string',' '); s=0.85*h; if mynumber<=16 t=0.026*w; else t=0.12*w;s=s+15*40; end fview=uicontrol(fh,'style','edit','position',[t s-mynumber*40 100 30],...%创建在编辑框中输入c0的edit 'fontsize',13,'string',num2str(C(1,mynumber-1))); end uicontrol(fh,'style','text','position',[0.3*w 0.7*h 80 30],'string','tp',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.3*w 0.66*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'callback',@fgettp); function fgettp(hObject, eventdata, handles)%对在编辑框中输入c0的响应 tP=str2num(get(hObject,'String')); end uicontrol(fh,'style','text','position',[0.3*w 0.58*h 80 30],'string','kp',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.3*w 0.54*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'callback',@fgetkp); function fgetkp(hObject, eventdata, handles)%对在编辑框中输入c0的响应 kP=str2num(get(hObject,'String')); end uicontrol(fh,'style','text','position',[0.3*w 0.46*h 80 30],'string','C',... 'fontsize',15); getC=uicontrol(fh,'style','popup','position',[0.3*w 0.42*h 80 30],'string',... '3|√3','fontsize',12,'callback',@fgetC); function fgetC(hObject, eventdata, handles)%对在编辑框中输入c0的响应 switch get(getC,'Value') case 1 c=3; case 2 c=sqrt(3); end end uicontrol(fh,'style','text','position',[0.3*w 0.34*h 80 30],'string','δ仪',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.3*w 0.3*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'callback',@fgetdeltay); function fgetdeltay(hObject, eventdata, handles)%对在编辑框中输入c0的响应 deltay=str2num(get(hObject,'String')); end uicontrol(fh,'style','text','position',[0.3*w 0.22*h 80 30],'string','δ人',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.3*w 0.18*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'callback',@fgetdeltar); function fgetdeltar(hObject, eventdata, handles)%对在编辑框中输入c0的响应 deltar=str2num(get(hObject,'String')); end uicontrol(fh,'style','pushbutton','position',[0.4*w 0.05*h 80 80],'fontsize',20,'string','计算','callback',@fcalculus); function fcalculus(hObject, eventdata, handles) mymean=mean(C); deltaN=std(C)*sqrt(mynumber-1/(mynumber-2)); uA=std(C)/sqrt(mynumber-2); uB=sqrt(deltay^2+deltar^2)/c; uP=sqrt((tP*uA)^2+(kP*uB)^2); uicontrol(fh,'style','text','position',[0.4*w 0.7*h 80 30],'string','平均值',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.4*w 0.66*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'string',num2str(mymean)); uicontrol(fh,'style','text','position',[0.4*w 0.58*h 80 30],'string','δN',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.4*w 0.54*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'string',num2str(deltaN)); uicontrol(fh,'style','text','position',[0.38*w 0.46*h 120 30],'string','A类不确定度',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.4*w 0.42*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'string',num2str(uA)); uicontrol(fh,'style','text','position',[0.38*w 0.34*h 120 30],'string','B类不确定度',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.4*w 0.3*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'string',num2str(uB)); uicontrol(fh,'style','text','position',[0.38*w 0.22*h 130 30],'string','展伸不确定度',... 'fontsize',15); uicontrol(fh,'style','edit','position',[0.4*w 0.18*h 80 30],...%创建在编辑框中输入c0的edit 'fontsize',12,'string',num2str(uP)); end clear C end |
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
我用matlab的coder 封装了一个c语言的dll, 但是在用labview调用时,会出现识别不到库的问题,有大神遇到过吗
2645 浏览 0 评论
5229 浏览 0 评论
在matlab中如何计算含有第一类修正的贝塞尔函数的积分算不出的问题?
9025 浏览 0 评论
怎么利用matlab得到95%,80%和70%的置信区间,并生成不同区间下的功率误差贝塔分布?
10466 浏览 0 评论
请问simulink的s-function模块如何添加多输入输出接口
14632 浏览 2 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 19:48 , Processed in 0.584732 second(s), Total 71, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4593