User input that can remain on screen and be adjusted?

1 次查看(过去 30 天)
I have only just in the last month or so learnt how to use MATLAB. I'm currently trying to make a basic GUI for a series of race car dynamics calculations.
I'm using questdlg and inside one case, prompt. The values entered in this prompt once OK is pressed are run through a series of equations, a graph appears, and the results are returned in a uiwait msgbox - once OK is pressed another graph is displayed (and the results go)
My question - how can I have functionality like this, but allow the user input box to remain on screen, and the results, and graphs, so one variable could be changed, and the effect on the results easily seen?
Currently I have to finish running the code (close graphs and msgbox) and re-run, re-typing all values, adjusting the one I want to change.
Do I need to use GUIDE? I avoided it initially as I knew a basic GUI (as it is now) with prompts/questdlg/msgbox would take only a few lines of code.
Please see my M-file - https://dl.dropboxusercontent.com/u/18683367/Code.m
Thanks in advance - Matt.
  4 个评论
Geoff Hayes
Geoff Hayes 2015-11-24
Matt - I think that creating a GUI with GUIDE is the best way to proceed. You seem to have about 15-16 attributes that the user is allowed to modify/edit and so using edit text boxes for each may be the way to go (especially if you allow the user to change one attribute and then want the graph to update soon after).
Matt
Matt 2015-11-24
Thanks Geoff - I think you might be right.
I've improved it - but I still want to pre-populate the input boxes with the original values the user entered on the initial run when the user chooses to edit the values - it seems there isn't a way to do this, but hopefully there is. If not it'll have to be GUIDE.
See the updated M-file if you like: https://dl.dropboxusercontent.com/u/18683367/DONE_GUI_improvement_trials.m

请先登录,再进行评论。

采纳的回答

Geoff Hayes
Geoff Hayes 2015-11-25
Matt - if you want to re-populate your input boxes with the list that the user had already selected then you can by making use of the default answers property of inputdlg. Since the output from your call to this function is the local variable answer, then do the following: outside of your while loop, initialize this local variable to be an empty cell array as
answer = {};
while choice_final == 'Yes'; %#ok<STCMP>
% etc.
Now, when it comes to launching the dialog, do
if isempty(answer)
answer=inputdlg(prompt,heading);
else
answer=inputdlg(prompt,heading,1,answer);
end
If the cell array is empty, as it would be the first time he user launches the dialog, then don't provide any default answers. Else, if the user chooses to edit some of his or her previous answers, then provide the answers from the previous "round".
As an aside, for your string compare use strcmp or strcmpi, so that the condition in your above while loop becomes
while strcmpi(choice_final,'yes')
% etc.
rather than using == to compare strings directly.
  2 个评论
Matt
Matt 2015-11-27
Thank you very very much!
With a bit of fiddling I got it working well. Much better than my other attempt where the user had to select the variable to edit in a listdlg and then type the value in an inputdlg - sounds ok but was a complete bodge job.
I will message you my file if you care to try it :)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by