Info

此问题已关闭。 请重新打开它进行编辑或回答。

How can I relate an object of a figure to an object of another figure?

1 次查看(过去 30 天)
Hi! I'm using the GUI to build a programm. I crieted a second figure which gets a information from user and should pass that informtation to a listbox.
Here is the second figure's programm:
function pbcanais_Callback(hObject, eventdata, handles) % the first figure's function
f = figure('Name','Incluir Canais','NumberTitle','off','Resize','off', 'rend','painters','pos',[500 300 250 150]);
%Cria a janela relacionando à figura f, ao tipo de dados, os dados a serem usados
%e a posição dela em f
set(f, 'MenuBar', 'none'); %Tirando a barra de menus
set(f, 'ToolBar', 'none');%Tirando a barra de ferramentas
stt1 = uicontrol(f, 'Style', 'text', 'String', 'Quantidade de canais', ...
'Position', [20 50 100 60], 'FontSize', 12);
% 'stt1' cria o static text "Quantidade de canais".
edt = uicontrol(f,'Style','edit','Position',[130 70 90 40], 'Tag', 'edtca', 'Callback', @edtca_callback);
%'edt' cria o edit text da tela.
stt2 = uicontrol(f, 'Style', 'text', 'String', 'Pressione ENTER para incluir',...
'Position', [27 7 200 50], 'FontSize', 10);
% 'stt2' cria o static text 'Pressione ENTER para incluir'.
%Função acionada quando pressionar enter
function edtca_callback(hObject,eventdata,handles) % the second figure's function
handles.edt1 = (get(hObject,'String'));
j = size(handles.edt1);
h = handles.edt1;
t=0;
x=0;
while t==0 && x~=j(1,2)
x=x+1;
k=h(1,x);
if isletter (k)%Verifica se o dado digita são letras
opts = struct('WindowStyle','nonmodal', 'Interpreter','tex'); %Permite modificações na janela de erro
errordlg('\fontsize{12} Insira apenas números','ATENÇÃO', opts);%exibe uma janela de erro
t=1;
elseif k == '!' || k== '@' || k == '#' || k == '$' || k == '%' || k == '¨' || k == '&' || k== '*' || k=='(' || k==')' || k == '-' || k == '_' || k == '+' || k == '='
opts = struct('WindowStyle','nonmodal', 'Interpreter','tex'); %Permite modificações na janela de erro
errordlg('\fontsize{12} Não insira caracteres','ATENÇÃO', opts);%exibe uma janela de erro
t=1;
else
end
end
if t == 0
load 'listcanais.mat'
dim = size(canais)
canais{dim(1,1)+1,1}= str2double(h);
save ('listcanais.mat','canais')
set(handles.listcanais,'String',canais);
end
guidata(hObject,handles);%função usada quando o valor varia

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by