?? 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 + -