inputdlg to call a function on click ok
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Walter Roberson
2012-11-24
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 个评论
Matt Fig
2012-11-24
编辑:Matt Fig
2012-11-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!