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.

回答(3 个)

Walter Roberson
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.

Matt Fig
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.

kyin gab
kyin gab 2012-11-25
Thank you Math and Walter. I am new to MathLab, I did not really get what you guys were saying.
I just figured out that when I clicked ok the inputdlg returns the typed input back to the function that called. So I can continued form there.
I have more questions, and I just posted one with the title 'plotting dtmf frequencies'.
Thank you guys.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by