how take input and save to an array in matlab gui

Hi,
I am new to matlab gui. Actually I want take input and then store them as an array using matlab gui. Can anybody guide me how to do that. Actually what I want is whenever I press push button what ever values in edit boxes they should save in an array. length of the array is decided by user in code.test.png

 Accepted Answer

Hi Muhammad,
In your exercise, you'd need to edit your function file (nested callback function for [Push Button]) obtained from your gui model test.fig. You can save/export the user entries to an external file or save in the workspace by editing the callback function of [Push Button] that should have get() and the conversion str2double() to convert the user entries from edit boxes. If you still can solve this, then post your code obtained from text.fig, so more specific directions can be given to you.
Good luck.

5 Comments

Hi,
Thanks for the guidance. now I am taking input and send to other function where it is save in mat file but still I am unable to understand how can I run push button in a nested loop. can you please elaborate it
Sulaymon Eshkabilov's answer moved here for consistency:
Let's say your [Push Button] has a tag name: "PUSH" then there must be a callback function called [PUSH_Callback(hObject, eventdata, handles)] inside (it has to be somewhere at the end of function file: test.m) your function file called test.m that starts with: function varargout=test(varargin) ...
You'd need to edit that callback function: [PUSH_Callback(hObject, eventdata, handles)] to make it save the user entries in your desired *.mat file. Moreover, you'd need to edit another callback plot_Callback(hObject, eventdata, handles) i.e. [plot] button (I am assuming that its tag is called "plot") to build a plot according to your plot assignment.
NB: name tags (Tag) of components can be found by double clicking on them or selecting a component and then clicking on [Property Inspector] from menu panel of test.fig in its edit mode.
Good luck.
Muhammad Haziq comments:
Hi Sulaymon,
Thanks for guiding me on this issue. I have done this task successfully but it seems that its not an good way I am uploading my code file and fig file. can you look it and suggest me something to make it more efficient. instead of plot I just show array values in command window.
Sulaymon Eshkabilov's answer moved here:
Hi Muhammad,
Here are the edited files (I have removed your created functions to save the user entries and assigned global variables that are not necessary).
The updated model plots and saves the user entries (under the callback function SAVE_Callback) for tmin and tmax (I have called them this way. You can change them as you want), computed function values (as an example, I have used f=sinc(t) function that you can change inside the callback function: PLOT_Callback). Moreover, I have included one addtional item to save the computed function values (plotted) and input argument space generated with linspace(). All of these you can change w.r.t your problem statements.
Good luck.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2019a

Community Treasure Hunt

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

Start Hunting!