📄 test.m
字号:
a1=cat(1,a1,b1);
t=1:y+2;
set(hline1,'xdata',t,'ydata',a1(:,2));
drawnow;
y=y+1;
set(huipushtool1,'clickedcallback',@huipushtool1_callback);
pause(sampletime);
end
% disconnect all objects.
fclose(obj1);
%clean up all objects.
delete(obj1);
clear obj1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%下面这个子函数是用来对当前的图形进行保存,用户可以保存成.bmp文件或.jpg或其它的等等格式。
function saveasfcn(hobject,eventdata,handles)
global hresult;
[filename, pathname, filterindex] = uiputfile( ...
{'*.bmp;*.fig;*.tif','Picture styles (*.bmp,*.fig,*.tif)';
'*.bmp', 'Bitmap-files (*.bmp)'; ...
'*.fig','Figures-files (*.fig)'; ...
'*.tif','Gif-files (*.tif)'; ...
'*.*', 'All Files (*.*)'}, ...
'Save as');
if isequal([filename,pathname],[0,0]) % If 'Cancel' was selected then return
return
else
File = fullfile(pathname,filename); % Construct the full path and save
saveas(hresult,File)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%这个函数用来弹出一个下拉式对话框,让用户选择一个通道。
function setup_dlg(hobject,eventdata,handles)
global hmainfig hresult;
allaxes=getappdata(hmainfig,'allaxes');
allline=getappdata(hmainfig,'allline');
channelstr={'channel 1','channel 2','channel 3','channel 4','channel 5','channel 6','channel 7','channel 8'};
[s,v]=listdlg('promptstring','请选择其中一个','selectionmode','single','name','请选择通道','liststring',channelstr,...
'fus',10,'listsize',[200 100]);
prompt={'Xmin','Xmax','Ymin','Ymax'};
title=['setup for channel_',sprintf('%g',s)];
defaults={'0','10000','-5','5'};
inputdlg_1=inputdlg(prompt,title,1,defaults);
axes_cells=str2num(char(inputdlg_1));
Xmin=axes_cells(1);
Xmax=axes_cells(2);
Ymin=axes_cells(3);
Ymax=axes_cells(4);
switch s
case 1
set(allaxes(1),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 2
set(allaxes(2),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 3
set(allaxes(3),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 4
set(allaxes(4),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 5
set(allaxes(5),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 6
set(allaxes(6),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 7
set(allaxes(7),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
case 8
set(allaxes(8),'xlim',[Xmin,Xmax],'ylim',[Ymin,Ymax]);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%这个子函数是用来对测量对象进行放大,会弹出一个输入框,让用户输入8个通道的倍数。
function equationdlg(hobject,eventdata,handles)
global hinput2;
prompt2={'请输入第一通道倍数:',...
'请输入第二通道倍数:',...
'请输入第三通道倍数:',...
'请输入第四通道倍数:',...
'请输入第五通道倍数:',...
'请输入第六通道倍数:',...
'请输入第七通道倍数:',...
'请输入第八通道倍数:'};
def2={'1','1','1','1','1','1','1','1'};
fields2={'equation1','equation2','equation3','equation4',...
'equation5','equation6','equation7','equation8'};
hinput2=inputdlg(prompt2,'Setup for equation',1,def2);
if ~isempty(hinput2)
hinput2=cell2struct(hinput2,fields2);
else
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%这个子函数是用来对测量单位进行设置,用户在弹出的对话框中输入8个通道的测量单位。
function measureunits(hobject,eventdata,handles)
global hinput1;
prompt1={'请输入第一通道的测量单位:',...
'请输入第二通道的测量单位:',...
'请输入第三通道的测量单位:',...
'请输入第四通道的测量单位:',...
'请输入第五通道的测量单位:',...
'请输入第六通道的测量单位:',...
'请输入第七通道的测量单位:',...
'请输入第八通道的测量单位:'};
def1={'mV','mA','mV','mA','mV','mA','mV','mA'};
fields1={'ch1units','ch2units','ch3units','ch4uits','ch5units','ch6units','ch7units','ch8units'};
hinput1=inputdlg(prompt1,'Setup for measure units',1,def1);
if ~isempty(hinput1);
hinput1=cell2struct(hinput1,fields1);
else
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%设置采样时间间隔,默认情况下该值为1。
function sampletimedlg(hobject ,eventdata,handles)
global sampletime;
prompt={'请输入数据采样间隔时间'};
def={'1'};
dlgtitle='Setup for sample time';
answer=inputdlg(prompt,dlgtitle,1,def);
if ~isempty(answer)
sampletime=str2num(char(answer));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%这个子函数是用来对当前的线进行设置线宽的。
function slider_callback(hobject,eventdata,handles)
global hmainfig hinput1 hinput2 hcurrent sampletime;
global hresult;
allaxes=getappdata(hmainfig,'allaxes');
allline=getappdata(hmainfig,'allline');
h2=figure('position',[250 250 200 200],'menubar','none','numbertitle','off','name','修改线宽','windowstyle','modal','visible','off');
hslider=uicontrol('style','slider','units','normalized','position',[0.4,0.1,0.1,0.6],'value',0.5,'max',5,'min',0);
set(hslider,'sliderstep',[0.02 0.05]);
movegui(h2,'center');
str1='当前的线宽是:';
ht1=uicontrol('style','text','position',[10 160 110 20],'string',str1,'backgroundcolor',[0.8,0.8,0.8]);
set(ht1,'fontsize',11);
set(ht1,'units','normalized');
ht2=uicontrol('style','text','position',[110 160 20 20],'string',0.5,'backgroundcolor',[0.8 0.8 0.8],'fontsize',11);
set(ht2,'units','normalized','foregroundcolor','b');
setappdata(hmainfig,'ht2',ht2);
setappdata(hmainfig,'hslider',hslider);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -