inputdlg to call a function on click ok
2 views (last 30 days)
Show older comments
Hello,
I would like the expert in the house to help me with this.
I have an inputdlg. I want when the ok button is pressed, it should automatically call another function which is stored as an m file. Also, it should pass its value answer as inout to that called function.
I would help here and some examples.
Thank you.
0 Comments
Answers (3)
Walter Roberson
on 24 Nov 2012
You would need to modify the code for inputdlg() to do that, or else create your own inputdlg.m function that was earlier on the path and did what you want.
0 Comments
Matt Fig
on 24 Nov 2012
Edited: Matt Fig
on 24 Nov 2012
There are may ways to do this:
P = {'Enter a number on [1,5]: '};
N = 'Input for ONES function.';
M = 1;
D = {'3'};
F = ones(str2double(inputdlg(P,N,M,D))) % Pass to ONES.
Note that it may be (read: is) a good idea to have some error checking instead of just passing the INPUTDLG call to STR2DOUBLE. For example, if the user enters pi, you will get an error... You could wrap all this code plus the error checking into a new function called, myinputdlg.m then use it as needed.
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!