Matlab GUI - parameters passing in function used in button callback
2 次查看(过去 30 天)
显示 更早的评论
I am calling a function encrypt(S,k) in encrypt button callback. I created the GUI using guide.
Here is the code for Encrypt function:
% --- Executes on button press in Encrypt. function Encrypt_Callback(hObject, eventdata, handles) s = get(handles.edit5,'String'); disp(s); %s = 'jyoti'; %plain text need to be stored from the edit box, user input global X; k = 'key'; % to be generated and stored by sender button... X = enc1(s,k); % X stores the cypher text set(handles.textStatus, 'String', X ); guidata(hObject, handles);
But when I pass s= ' any string', the enc1 works and when I try to store and pass the text from edit box, there comes the following errors:
Error in ==> enc1 at 12 if (ischar(s)==0)
??? Output argument "X" (and maybe others) not assigned during call to "C:\Users\Jyoti\Documents\MATLAB\MATLAB\enc1.m>enc1".
Error in ==> gui>Encrypt_Callback at 278 X = enc1(s,k); % X stores the cypher text
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> gui at 43 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)gui('Encrypt_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Help!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!