MATLAB CODE FOR NEXT PAGE IN GUI
2 次查看(过去 30 天)
显示 更早的评论
Hi, I made a GUI program where I examine graphs from measured data in a text file. The GUI works as follows: The first title page, after clicking on the "NAJÍT DATA" button, I select a text file and graphs are displayed including all the functions that I have programmed.
However, my problem...
I can't fit all the information I need in the first window. Therefore, I would like to add a button called "MAP" that will launch another (second) GUI window (page). I would like to use code to insert a map, other graphs, etc. into this window. And at the same time I'd like to keep the first GUI window with graphs etc.
Is this possible? I've been puzzling over this for two days now and can't get it to work. Any advice would be greatly appreciated!!
For testing, below is the code of my program with an attached text document and needed picture.
%--------------------------------------------------------------------
% APLIKACE PRO MĚŘENÍ ROVINATOSTI LETIŠTNÍCH PLOCH S GUI (ORIGINÁL) -
% DATUM: 10.06.2022 -
% VERZE: 1.1 -
% ZPRACOVAL: pplk. gšt. Ing. Ph.D. Luděk ČIČMANEC -
% rtm. ček. Adam KUBICA -
%--------------------------------------------------------------------
function gui_LP_01 (vstpar)
if nargin==0
%[0.8 0.8 0.8]
f=figure('color', [1 1 1], 'name', 'GUI LP ver.01', 'numbertitle', 'off','menubar', 'none', 'units', 'norm',...
'position', [0.1 0.07 0.85 0.85],'tag', 'figure1', 'closerequestfcn', ' '); % ÚVODNÍ OBRÁZEK
set(f,'toolbar','figure'); % TOOLBAR
% TITULNÍ OBRÁZEK
fi=axes('units', 'norm', 'position',[0.35 0.35 0.25 0.25],'tag', 'axesfi');
cdata = imread('obr1.png');
im = image(cdata,'Parent',fi);
fi.XTick = []; % ODSTRANÍ OSU OBRÁZKU
fi.YTick = [];
fi.Visible = 'off'; % ODSTRANÍ RÁMEČEK OBRÁZKU
% PUSHBUTTONS -----------------------------------------------------------------------------------------------------------------%
% NAHRÁNÍ DAT Z TEXTOVÉHO SOUBORU
uicontrol('units', 'norm', 'position', [0.83 0.02 0.09 0.03], 'style', 'push', 'tag', 'najit', 'string',...
'NAHRÁT DATA', 'fontsize', 12, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.3010, 0.7450, 0.9330], 'callback', 'gui_LP_01 najit');
% UKONČENÍ PROGRAMU
uicontrol('units', 'norm', 'position', [0.93 0.02 0.06 0.03], 'style', 'push', 'tag', 'konec', 'string',...
'UKONČIT', 'fontsize', 12, 'foregroundcolor', [0 0 0],'backgroundcolor','y', 'callback', 'gui_LP_01 konec');
%------------------------------------------------------------------------------------------------------------------------------%
else
switch (vstpar)
case ('konec')
% close all
delete (get (0, 'children')) % zavreni vseho
case('najit') % najit data
cla % smaže všechny grafy včetně os cla reset pouze graf osy zůstanou
[filename, pathname] = uigetfile('*.txt','Select file to read message'); % filename
% selected data display
if isequal(filename,0)
disp('User selected Cancel')
else
delete (findobj('tag','axes1')); %smaže původní graf
delete (findobj('tag','axes2')); %smaže původní graf
delete (findobj('tag','axes3')); %smaže původní graf
delete (findobj('tag','axes4')); %smaže původní graf
delete (findobj('tag','axes5')); %smaže původní graf
delete (findobj('tag','axes6')); %smaže původní graf
delete (findobj('tag','axes7')); %smaže původní graf
delete (findobj('tag','axes8')); %smaže původní graf
disp(['User selected ', fullfile(pathname, filename)])
end
% ULOŽENÍ DAT, MATICE X
% X = dlmread(filename); %[R1 C1 R2 C2]
% X=csvread(filename,262,0); % restrict reading from 3 sec = 262 row
X=csvread(filename,4,0); % no restriction
t=X(:,1);
% tout = t(2:end) - t(1); % jak přidat jeden řádek?
%------------------------------------------------------------------------------------------------------------------------------%
% PANEL OVLÁDÁNÍ
uipanel('units','norm','position',[0.85 0.33 0.145 0.19],'title','FILTR','backgroundcolor', get(gcf,'color'),...
'fontsize',12,'foregroundcolor',[0.9 0.9 0.9],'tag','panel');
% GRAFY ZNÁZORŇUJÍCÍ ZRYCHLENÍ V JEDNOTLIVÝCH OSÁCH ---------------------------------------------------------------------------%
% GRAF ZRYCHLENÍ V OSE X
% x=X(:,2); % DATA Z DRUHÉHO SLOUPCE TEXTOVÉHO SOUBORU
Mx=mean(X(:,2)); % KALIBRACE NA STŘEDNÍ HODNOTU
x=X(:,2)-Mx;
ax1=axes('units', 'norm', 'position', [0.045 0.73 0.50 0.24], 'color', [0.7 0.7 0.7], 'tag', 'axes1');
xlabel ('T [s]', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY X
ylabel ('Zrychlení Xg (m/s^2)', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY Y
set (ax1, 'fontsize', 9) % VELIKOST FONTU POPISKU OS
grid on % MŘÍŽKA GRAFU
box on % RÁM GRAFU
L1=line(t, x, 'color', 'green', 'linewidth',1, 'parent', ax1); % VYKRESLÍ PRŮBĚH SIGNÁLU
% MOVING AVERAGE FILTER
%samplesPerSec=3;
%coeff=ones(1,samplesPerSec)/samplesPerSec;
%avgx=filter(coeff,1,x);
%fDelay = (length(coeff)-1)/57.7; % CENTRUJE POČÁTEK FILTRU NA 0
%tdx=t-fDelay/86;
%hold on
% SAVITZKY-GOLAY FILTER
order = 4;
framelen = 9;
avgx = sgolayfilt(x, order, framelen);
tdx=t;
hold on
L2=line(tdx,avgx, 'color', 'blue', 'linewidth',2, 'parent', ax1);
L=[L1 L2]; % HANDLE
ax1=gca;
set (ax1, 'userdata',L) % do uschovny [CO TO ZNAMENÁ?]
legend('Xg', 'Filtr', 'location', 'northeast'); % LEGENDA
%legend('boxoff'); % ODSTRANÍ RÁMEČEK LEGENDY
% TLAČÍTKO PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE X
c = uicontrol('units','norm','position',[0.93 0.45 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0], 'backgroundcolor', [1 0 0]);
c.String = 'FILTR1 OFF';
c.Callback = @(a,b)Filtr1_OFF(L2);
% TLAČÍTKO PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE X
c = uicontrol('units','norm','position',[0.86 0.45 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0 1 0]);
c.String = 'FILTR1 ON';
c.Callback = @(a,b)Filtr1_ON(L2);
%...........................................................%
% GRAF ZRYCHLENÍ V OSE Y
% y=X(:,3); % DATA Z TŘETÍHO SLOUPCE TEXTOVÉHO SOUBORU
My=mean(X(:,3)); % KALIBRACE NA STŘEDNÍ HODNOTU
y=X(:,3)-My; % [0.6 0.5 0.8]
ax2=axes('units', 'norm', 'position', [0.045 0.42 0.50 0.24], 'color', [0.7 0.7 0.7], 'tag', 'axes2');
xlabel ('T [s]', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY X
ylabel ('Zrychlení Yg (m/s^2)', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY Y
set (ax2, 'fontsize', 9) % VELIKOST FONTU POPISKU OS
grid on % MŘÍŽKA GRAFU
box on % RÁM GRAFU
L3=line(t, y, 'color', [0 1 0], 'linewidth', 1, 'parent', ax2); % VYKRESLÍ PRŮBĚH SIGNÁLU
% MOVING AVERAGE FILTER YG
%samplesPerSec=3;
%avgy=filter(coeffy,1,y);
%fDelayy = (length(coeffy)-1)/57.7; % CENTRUJE POČÁTEK FILTRU NA 0
%tdy=t-fDelayy/86;
%hold on
% SAVITZKY-GOLAY FILTER YG
%order = 4;
%framelen = 9;
%avgy = sgolayfilt(y, order, framelen);
%tdy=t;
%hold on
% DENOISING YG
avgy = wdenoise(y, 3, 'Wavelet', 'db4', 'DenoisingMethod', 'Bayes', 'ThresholdRule', 'Median', 'NoiseEstimate', 'LevelIndependent');
tdy = t;
hold on;
% FINDPEAKS YG
%findpeaks(avgy,tdy, 'MinPeakDistance',0.005, 'MinPeakProminence',0.07); % NAJDE VRCHOLY ZRYCHLENÍ
LMax = islocalmax(avgy, MaxNumExtrema=18, MinProminence=0.035, ProminenceWindow=1); % NAJDE KLADNÉ VRCHOLY ZRYCHLENÍ
LMin = islocalmin(avgy, MaxNumExtrema=18, MinProminence=0.029, ProminenceWindow=1); % NAJDE ZÁPORNÉ VRCHOLY ZRYCHLENÍ
%var2 LMax = islocalmax(avgy, MaxNumExtrema=18, MinProminence=0.035, ProminenceWindow=1, MinSeparation=0);
% LMin = islocalmin(avgy, MaxNumExtrema=18, MinProminence=0.029, ProminenceWindow=1, MinSeparation=0);
L4=line(tdy, avgy, 'color', 'yellow', 'linewidth',2, 'parent', ax2);
Ly=[L3 L4];
LMax1=plot(tdy,avgy,tdy(LMax),avgy(LMax),'rx', 'linewidth', 2, LineStyle='none'); % NASTAVENÍ LMax
LMin1=plot(tdy,avgy,tdy(LMin),avgy(LMin),'b*', 'linewidth', 1, LineStyle='none'); % NASTAVENÍ LMin
hold on
ax2=gca;
set (ax2, 'userdata',Ly) % do uschovny [CO TO ZNAMENÁ?]
legend('Yg', 'Filtr', 'location', 'northeast'); % LEGENDA
%legend('boxoff'); % ODSTRANÍ RÁMEČEK LEGENDY
% TLAČÍTKO PRO SKRYTÍ LMax
c = uicontrol('units','norm','position',[0.75 0.45 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0], 'backgroundcolor', [1 0 0]);
c.String = 'YgMax OFF';
c.Callback = @(a,b)LMax1_OFF(LMax1);
% TLAČÍTKO PRO ZOBRAZENÍ LMax
c = uicontrol('units','norm','position',[0.68 0.45 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0 1 0]);
c.String = 'YgMax ON';
c.Callback = @(a,b)LMax1_ON(LMax1);
% TLAČÍTKO PRO SKRYTÍ LMin
c = uicontrol('units','norm','position',[0.75 0.40 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [1 0 0]);
c.String = 'YgMin OFF';
c.Callback = @(a,b)LMin1_OFF(LMin1);
% TLAČÍTKO PRO ZOBRAZENÍ LMin
c = uicontrol('units','norm','position',[0.68 0.40 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0 1 0]);
c.String = 'YgMin ON';
c.Callback = @(a,b)LMin1_ON(LMin1);
% TLAČÍTKO PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE Y
c = uicontrol('units','norm','position',[0.93 0.40 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [1 0 0]);
c.String = 'FILTR2 OFF';
c.Callback = @(a,b)Filtr2_OFF(L4);
% TLAČÍTKO PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE Y
c = uicontrol('units','norm','position',[0.86 0.40 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0 1 0]);
c.String = 'FILTR2 ON';
c.Callback = @(a,b)Filtr2_ON(L4);
%...........................................................%
% ZRYCHLENÍ V OSE Z
% z=-X(:,4); % DATA Z ČTVRTÉHO SLOUPCE TEXTOVÉHO SOUBORU
Mz=mean(X(:,4)); % KALIBRACE NA STŘEDNÍ HODNOTU
z=X(:,4)-Mz;
ax3=axes('units', 'norm', 'position', [0.045 0.10 0.50 0.24], 'color', [0.7 0.7 0.7], 'tag', 'axes3');
xlabel ('T [s]', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY X
ylabel ('Zrychlení Zg (m/s^2)', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY Y
set (ax3, 'fontsize', 9) % VELIKOST FONTU POPISKU OS
grid on % MŘÍŽKA GRAFU
box on % RÁM GRAFU
L5=line(t,z, 'color', 'green', 'linewidth',1, 'parent', ax3); % VYKRESLÍ PRŮBĚH SIGNÁLU
% MOVING AVERAGE FILTER ZG
%samplesPerSec=3;
%coeffz=ones(1,samplesPerSec)/samplesPerSec;
%avgz=filter(coeffz,1,z);
%fDelayz = (length(coeffz)-1)/57.7; % CENTRUJE POČÁTEK FILTRU NA 0
%tdz=t-fDelayz/86;
%hold on
% SAVITZKY-GOLAY FILTER ZG
%order = 4;
%framelen = 9;
%avgz = sgolayfilt(z, order, framelen);
%tdz=t;
%hold on
% DENOISING ZG
avgz = wdenoise(z, 3, 'Wavelet', 'db4', 'DenoisingMethod', 'Bayes', 'ThresholdRule', 'Median', 'NoiseEstimate', 'LevelIndependent');
tdz = t;
hold on;
% FINDPEAKS ZG
ZgMax = islocalmax(avgz, MaxNumExtrema=18, MinProminence=0.160); % NAJDE KLADNÉ VRCHOLY ZRYCHLENÍ
ZgMin = islocalmin(avgz, MaxNumExtrema=18, MinProminence=0.150); % NAJDE ZÁPORNÉ VRCHOLY ZRYCHLENÍ
L6=line(tdz,avgz, 'color', 'white', 'linewidth',2, 'parent', ax3);
Lz=[L5 L6]; % HANDLE
ZgMax1=plot(tdz,avgz,tdz(ZgMax),avgz(ZgMax),'rx', 'linewidth', 2, LineStyle='none'); % NASTAVENÍ LMax
ZgMin1=plot(tdz,avgz,tdz(ZgMin),avgz(ZgMin),'b*', 'linewidth', 1, LineStyle='none'); % NASTAVENÍ LMin
ax3=gca;
set (ax3, 'userdata',Lz) % do uschovny [CO TO ZNAMENÁ?
legend('Zg','Filtr','location','northeast'); % LEGENDA
%legend('boxoff'); % ODSTRANÍ RÁMEČEK LEGENDY
% TLAČÍTKO PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE Z
c = uicontrol('units','norm','position',[0.93 0.35 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [1 0 0]);
c.String = 'FILTR3 OFF';
c.Callback = @(a,b)Filtr3_OFF(L6);
% TLAČÍTKO PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE Z
c = uicontrol('units','norm','position',[0.86 0.35 0.06 0.03], 'style', 'push', 'tag', 'string',...
'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0 1 0]);
c.String = 'FILTR3 ON';
c.Callback = @(a,b)Filtr3_ON(L6);
%...........................................................%
% GRAF RYCHLOSTI VOZIDLA PŘI SBĚRU DAT
% z=-X(:,5); % DATA Z PÁTÉHO SLOUPCE TEXTOVÉHO SOUBORU
Mv=mean(X(:,5)); % KALIBRACE NA STŘEDNÍ HODNOTU
v=X(:,5);
ax4=axes('units', 'norm', 'position', [0.6 0.73 0.39 0.24], 'color', [0.7 0.7 0.7], 'xlim', [0 inf],'ylim', [12 16], 'tag', 'axes4');
xlabel ('T [s]', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY X
ylabel ('Rychlost V (m/s)', 'fontsize', 10, 'fontweight', 'bold') % POPIS OSY Y
set (ax4, 'fontsize', 9) % VELIKOST FONTU POPISKU OS
grid on % MŘÍŽKA GRAFU
box on % RÁM GRAFU
L5=line(t,v, 'color', 'green', 'linewidth',2, 'parent', ax4); % VYKRESLÍ PRŮBĚH SIGNÁLU
legend('Rychlost V','Filtr','location','northeast'); % LEGENDA
% legend('boxoff'); % ODSTRANÍ RÁMEČEK LEGENDY
%------------------------------------------------------------------------------------------------------------------------------%
% OBRÁZEK V GUI ---------------------------------------------------------------------------------------------------------------%
% fi2=axes('units', 'norm', 'position', [0.60 0.40 0.2 0.2], 'tag', 'axes0');
% cdata = imread('obr1.png');
% im = image(cdata,'Parent',fi2);
% fi2.XTick = []; %smazání osy
% fi2.YTick = [];
% fi2.Visible = 'off'; % ODSTRANÍ RÁMEČEK OBRÁZKU
% POSUN GRAFU DO JEDNOTLIVÝCH ČASOVÝCH ÚSEKŮ ----------------------------------------------------------------------------------%
% TLAČÍTKA PRO JEDNOTLIVÉ ČASOVÉ ÚSEKY GRAFŮ ----------------------------------------------------------------------------------%
% GRAF V ČASE T = 0-5sek
uicontrol('units', 'norm', 'position', [0.86 0.25 0.13 0.03], 'style', 'push', 'tag', '0-5', 'string',...
'ČASOVÝ ÚSEK T=0-5 [s]', 'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.9290, 0.6940, 0.1250], 'callback', 'gui_LP_01 0-5');
% GRAF V ČASE T = 5-10sek
uicontrol('units', 'norm', 'position', [0.86 0.20 0.13 0.03], 'style', 'push', 'tag', '5-10', 'string',...
'ČASOVÝ ÚSEK T=5-10 [s]', 'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.9290, 0.6940, 0.1250], 'callback', 'gui_LP_01 5-10');
% GRAF V ČASE T = 10-15sek
uicontrol('units', 'norm', 'position', [0.86 0.15 0.13 0.03], 'style', 'push', 'tag', '10-15', 'string',...
'ČASOVÝ ÚSEK T=10-15 [s]', 'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.9290, 0.6940, 0.1250], 'callback', 'gui_LP_01 10-15');
% GRAF V ČASE T = 15-20sek
uicontrol('units', 'norm', 'position', [0.86 0.1 0.13 0.03], 'style', 'push', 'tag', '15-20', 'string',...
'ČASOVÝ ÚSEK T=15-20 [s]', 'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.9290, 0.6940, 0.1250], 'callback', 'gui_LP_01 15-20');
%------------------------------------------------------------------------------------------------------------------------------%
% GRAF V ČASE T = 0-5sek ---------------------------------------%
case('0-5')
U=get(findobj('tag','0-5'),'value');
if U==1
set (findobj('tag','axes1'), 'xlim', [0 5]);
set (findobj('tag','axes2'), 'xlim', [0 5]);
set (findobj('tag','axes3'), 'xlim', [0 5]);
set (findobj('tag','axes4'), 'xlim', [0 5]);
else
set (findobj('tag','axes1'),'xlim', [0 5])
set (findobj('tag','axes2'),'xlim', [0 5])
set (findobj('tag','axes3'),'xlim', [0 5])
set (findobj('tag','axes4'),'xlim', [0 5])
end
% GRAF V ČASE T = 5-10sek --------------------------------------%
case('5-10')
V=get(findobj('tag','5-10'),'value');
if V==1
set (findobj('tag','axes1'),'xlim', [5 10])
set (findobj('tag','axes2'),'xlim', [5 10]);
set (findobj('tag','axes3'),'xlim', [5 10]);
set (findobj('tag','axes4'),'xlim', [5 10]);
else
set (findobj('tag','axes1'), 'xlim', [5 10]);
set (findobj('tag','axes2'), 'xlim', [5 10]);
set (findobj('tag','axes3'), 'xlim', [5 10]);
set (findobj('tag','axes4'), 'xlim', [5 10]);
end
% GRAF V ČASE T = 10-15sek -------------------------------------%
case('10-15')
J=get(findobj('tag','10-15'),'value');
if J==1
set (findobj('tag','axes1'),'xlim', [10 15]);
set (findobj('tag','axes2'),'xlim', [10 15])
set (findobj('tag','axes3'),'xlim', [10 15]);
set (findobj('tag','axes4'),'xlim', [10 15]);
else
set (findobj('tag','axes1'), 'xlim', [10 15]);
set (findobj('tag','axes2'), 'xlim', [10 15]);
set (findobj('tag','axes3'), 'xlim', [10 15]);
set (findobj('tag','axes4'), 'xlim', [10 15]);
end
% GRAF V ČASE T = 15-20sek -------------------------------------%
case('15-20')
P=get(findobj('tag','15-20'),'value');
if P==1
set (findobj('tag','axes1'),'xlim', [15 20]);
set (findobj('tag','axes2'),'xlim', [15 20]);
set (findobj('tag','axes3'),'xlim', [15 20])
set (findobj('tag','axes4'),'xlim', [15 20]);
else
set (findobj('tag','axes1'), 'xlim', [15 20]);
set (findobj('tag','axes2'), 'xlim', [15 20]);
set (findobj('tag','axes3'), 'xlim', [15 20]);
set (findobj('tag','axes4'), 'xlim', [15 20]);
end
end % KONEC SWITCH
end % OD NARGIN
end % KONEC FUNKCE gui_LP_01
%------------------------------------------------------------------------------------------------------------------------------%
% DALŠÍ FUNKCE ----------------------------------------------------------------------------------------------------------------%
% FUNKCE PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE X
function Filtr1_OFF(L2)
L2.Visible = 'off';
end
% FUNKCE PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE X
function Filtr1_ON(L2)
L2.Visible = 'on';
end
%-------------------------------------------------------------------------%
% FUNKCE PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE Y
function Filtr2_OFF(L4)
L4.Visible = 'off';
end
% FUNKCE PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE Y
function Filtr2_ON(L4)
L4.Visible = 'on';
end
%-------------------------------------------------------------------------%
% FUNKCE PRO SKRYTÍ FILTRU GRAFU ZRYCHLENÍ V OSE Z
function Filtr3_OFF(L6)
L6.Visible = 'off';
end
% FUNKCE PRO ZOBRAZENÍ FILTRU GRAFU ZRYCHLENÍ V OSE Z
function Filtr3_ON(L6)
L6.Visible = 'on';
end
%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%
% FUNKCE PRO SKRYTÍ LMax
function LMax1_OFF(LMax1)
set(LMax1,'visible','off');
end
%-------------------------------------------------------------------------%
% FUNKCE PRO ZOBRAZENÍ LMax
function LMax1_ON(LMax1)
set(LMax1,'visible','on');
end
%-------------------------------------------------------------------------%
% FUNKCE PRO SKRYTÍ LMin
function LMin1_OFF(LMin1)
set(LMin1,'visible','off');
end
%-------------------------------------------------------------------------%
% FUNKCE PRO ZOBRAZENÍ LMax
function LMin1_ON(LMin1)
set(LMin1,'visible','on');
end
%-------------------------------------------------------------------------%
%------------------------------------------------------------------------------------------------------------------------------%
0 个评论
回答(1 个)
Walter Roberson
2023-2-20
In every case in which you construct a graphics object, you should specify the parent object to insert the new object into, if possible.
Your lines such as
L5=line(t,z, 'color', 'green', 'linewidth',1, 'parent', ax3)
are a good start on that; you just need to take it further. For example,
ax4=axes('units', 'norm', 'position', [0.6 0.73 0.39 0.24], 'color', [0.7 0.7 0.7], 'xlim', [0 inf],'ylim', [12 16], 'tag', 'axes4');
should be told which graphics container the axes should be placed into.
In every case in which you use operations such as grid on you should specify the axes the operation applies to.
In every call to legend(), specify either the target axes or else the subset of objects to work with.
For calls such as
findobj('tag','axes1')
you should specify the starting object to descend from -- often a figure object but could be more specific. The exception to this would be if you are willing to ensure that your tags are going to be unique between figures -- no axes1 in both the first and second figures for example. Unless, that is, you are willing to have all axes with the same tag be updated simultaneously.
uicontrol('units', 'norm', 'position', [0.86 0.25 0.13 0.03], 'style', 'push', 'tag', '0-5', 'string',...
'ČASOVÝ ÚSEK T=0-5 [s]', 'fontsize', 10, 'foregroundcolor', [0 0 0],'backgroundcolor', [0.9290, 0.6940, 0.1250], 'callback', 'gui_LP_01 0-5');
Reminder: when you specify a Callback for a graphic object in the form of a string() object or a character vector, then the text will be executed in the context of the base workspace, and any functions named must be publicly available. The above uicontrol callback would not work if gui_LP_01 were a private function inside another function, for example. And the text will not have access to any local variables in the workspace of the function that established the callback text.
2 个评论
Walter Roberson
2023-2-20
There are two challenges to multiple windows:
- code getting them confused, especially taking actions on the "wrong" window. Parenting everything solves this (except for a couple of graphics functions that you have to hack the return structures for.)
- separating data for the windows but also sharing it when needed. The usual data sharing guidelines apply. If you were using GUIDE and the guidata() helpers, I would have given an additional hint.
As far as MATLAB is concerned, as "GUI" is a figure object that has behaviour attached to it. MATLAB does not have any such thing as a "graphics only" window. Even simple plot(1:20) output has behaviour attached to it, such as zoom behaviour. Your code can open and close windows as needed, and make them invisible or visible as needed. Nothing special needs to be done such as "tell the second gui, close yourself": you just delete() the graphics object handle, same as if you were working with the first window.
It is often convenient to separate out local variables for each "gui" to make it easier to write the code for each gui mostly independently without worrying about whether the same variable name happened to already be used for a different gui. But that is not mandatory.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!