How can i enter the input in MATLAB GUI ?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello Everyone,
I'm trying to design a gui. In GUI, MATLAB will give random 5 characters and user will enter the same 5 characters. How can i enter the input in MATLAB ? I used Edit Text but it won't work.
4 Commenti
Rik
il 30 Mag 2019
How should the user be entering characters?
And please use the layout tools when posting a comment.
Jan
il 1 Lug 2019
@Yusuf: "I used Edit Text but it won't work." - please mention any details about the problem. " I cannot do that" does not reveal also, what the actual problem is.
By the way, a simplification:
actualCell = allSymbols(randi([1, numel(allSymbols)], M, 1);
% I do not understand, why you replace \ by \\, but this is easier:
forScreen = strrep(actualCell, char(92), '\\');
set(handles.q1, 'String', forScreen{1});
set(handles.q2, 'String', forScreen{2});
set(handles.q3, 'String', forScreen{3});
set(handles.q4, 'String', forScreen{4});
set(handles.q5, 'String', forScreen{5});
Risposte (1)
Murugan C
il 1 Lug 2019
Hi Yusuf, I have created simple layout for your queris. I hope this attached gui files should resolve your issue. If it is not, please post your full code or attach your files.
![user_input1.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227014/user_input1.jpeg)
![user_input2.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227015/user_input2.jpeg)
![user_input3.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227016/user_input3.jpeg)
8 Commenti
Jan
il 2 Lug 2019
I prefer to create GUIs programmatically, because then I have full control and the GUIs are working under Matlab 7.0 to 2019a without incompatibilities (with some limitations, e.g. that the graphic handles are not assumed to be doubles and no string classes are used). I keep the actual computations separated from the GUI code to allow for an easier maintenance.
My GUIs get some default parameters from a specific function, e.g. fonts, scaling factors, color schemes and default positions, e.g. the last used position with an automatic reset if a 2nd monitor has been switched off.
For a beginner this method would be an overkill. GUIDE and AppDesigner let you create a GUI much faster and with less groundwork. The drawback of incompatibilities between different Matlab versions and the limited possibilities are less important than. If you want to create one or three GUIs, GUIDE and AppDesigner are efficient. For a professional programmer and for 72 GUIs, these tools are too dull. The differentiation is easy:
How much programming time does it cost until the GUIs do, what you need?
Or in other words: You should use GUIDE, if it solves your problem efficiently, and vice-versa.
Rik
il 2 Lug 2019
Maybe I should write GUIDE2.0 some day, then I could suggest using that for the cases where you want rapid prototyping. Functions like the one you describe for default parameters would be ideal. A function like the one below can also be useful in building a GUI, but they look intimidating really quickly.
But let's be realistic: that is a huge amount of work, so I probably won't actually do it. Maybe if there are other people willing to participate in the effort. I suspect our time is more helpfully spent on this forum than on creating GUIDE2.0.
function fig=blank_figure(varargin)
%Create a blank figure that has no fancy controls or menus.
%
% Inputs are piped to figure(), so all the normal syntaxes are supported.
%
% Creating a figure without bells and whistles is especially useful if you
% want a robust way to generate an image without the possibility of user
% interaction leading to unexpected behavior.
% Another use case is the creation of a GUI, where it is better to manually
% add back any extra controls that the required releases support.
%
% This function is compatible with all Matlab releases
fig=figure(varargin{:});
% To remove the new interactions (introduced in R2018b), we need to use
% some tricks.
%
% Use eval to trick the syntax checking in ML6.5 (both the ~ and the @ trip
% up the syntax checker).
%
% Using evalc ensures that you can group functions in a single anonymous
% function that otherwise have no output (as neither set() nor
% disableDefaultInteractivity() have output arguments).
persistent defaultAxesCreateFcn
if isempty(defaultAxesCreateFcn)
defaultAxesCreateFcn=eval(['@(ax,~){',...
'evalc(''set(ax.Toolbar,''''Visible'''',''''off'''')''),',...
'evalc(''disableDefaultInteractivity(ax)'')}']);
end
%We only need to modify the creator function on >=R2018b
try %#ok if verLessThan is missing verLessThan would have returned true
if ~verLessThan('matlab','9.5')
set(fig,'defaultAxesCreateFcn', ...
defaultAxesCreateFcn);
end
end
%remmove other controls to ensure a blank figure
set(fig,'Menu','none','Toolbar','none');
end
Vedere anche
Categorie
Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!