📄 da_2dsc.m
字号:
%
% da_2dsc
%
% Programme for plotting 2D scatter graphs
%
% Sort the screen out
%
da_front;
w1=gcf;
drawnow;
ax1=axes(...
'Units','pixels',...
'Position',[50 150 500 250],...
'Box','on',...
'Color',[0 0 0],...
'Visible','on');
%
% Print a title
%
text1=da_text(w1,190,405,250,15,'2D scatter plot',[1 1 1],[1 0 0]);
%
% Display some text that shows correlation
%
text2=da_text(w1,200,20,250,15,'Correlation Output to Input = ',[1 1 1],[0 0 1]);
%
% Plot the principal component
%
plot(data(:,1),data(:,2),'+');
c=corrcoef(data(:,1),data(:,2));
set(text2,'string',['Correlation Output to Input = ' num2str(c(2,1))]);
Xlabel('Input value');
Ylabel('Output value');
old_val1=1;
old_val2=2;
sl1_value=1;
sl2_value=2;
p_style=0;
[dummy num_pcs]=size(data);
%
% Have a slider to change which pc to plot
%
sl1=uicontrol(w1,...
'Style','slider',...
'Position',[50 60 200 20],...
'Min',1,...
'Max',num_pcs,...
'Value',1,...
'CallBack',[
'set(sl1_current,''String'',ceil(get(sl1,''Value'')));',...
'sl1_value=ceil(get(sl1,''Value''));',...
'if sl1_value ~= old_val1;',...
'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
'if p_style == 0;',...
'cla;',...
'plot(data(:,sl1_value),data(:,sl2_value),''+'');',...
'else;',...
'cla;',...
'plotnum(data(:,sl1_value),data(:,sl2_value),ax1);',...
'end;',...
'old_val1=sl1_value;',...
'Xlabel(''Input value'');',...
'Ylabel(''Output value'');',...
'c=corrcoef(data(:,sl1_value),data(:,sl2_value));',...
'set(text2,''string'',[''Correlation Output to Input = '' num2str(c(2,1))]);',...
'end;']);
sl1_current=uicontrol(w1,...
'Style','text',...
'Position',[225 85 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(get(sl1,'Value')));
sl1_min=uicontrol(w1,...
'Style','text',...
'Position',[30 60 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','1');
sl1_max=uicontrol(w1,...
'Style','text',...
'Position',[250 60 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl1_title=uicontrol(w1,...
'Style','text',...
'Position',[45 85 180 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','Select an input variable');
%
% Now draw a slider to define the principal component plotted
% on the y-axis
%
sl2=uicontrol(w1,...
'Style','slider',...
'Position',[370 60 200 20],...
'Min',1,...
'Max',num_pcs,...
'Value',sl2_value,...
'CallBack',[
'set(sl2_current,''String'',ceil(get(sl2,''Value'')));',...
'sl2_value=ceil(get(sl2,''Value''));',...
'if sl2_value ~= old_val2;',...
'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
'if p_style == 0;',...
'cla;',...
'plot(data(:,sl1_value),data(:,sl2_value),''+'');',...
'else;',...
'cla;',...
'plotnum(data(:,sl1_value),data(:,sl2_value),ax1);',...
'end;',...
'old_val2=sl2_value;',...
'Xlabel(''Input variable'');',...
'Ylabel(''Output variable'');',...
'c=corrcoef(data(:,sl1_value),data(:,sl2_value));',...
'set(text2,''string'',[''Correlation Output to Input = '' num2str(c(2,1))]);',...
'end;']);
sl2_current=uicontrol(w1,...
'Style','text',...
'Position',[550 85 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(get(sl2,'Value')));
sl2_min=uicontrol(w1,...
'Style','text',...
'Position',[350 60 15 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','1');
sl2_max=uicontrol(w1,...
'Style','text',...
'Position',[570 60 20 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String',num2str(num_pcs));
sl2_title=uicontrol(w1,...
'Style','text',...
'Position',[370 85 170 15],...
'BackGroundColor',[0 0 0],...
'ForeGroundColor',[1 1 1],...
'String','Select an output variable');
%
% Two buttons for plot numbers or plot crosses
%
but3=uicontrol(w1,...
'style','push',...
'position',[560 350 55 30],...
'string','1,2,3,...',...
'callback',[
'cla;',...
'plotnum(data(:,sl1_value),data(:,sl2_value),ax1);',...
'p_style=1;']);
but4=uicontrol(w1,...
'style','push',...
'position',[560 300 55 30],...
'string','+++',...
'callback',[
'cla;',...
'plot(data(:,sl1_value),data(:,sl2_value),''+'');',...
'p_style=0;']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -