0

Hi iI have a small GUI that contains 1 'Push Button' and 3 'Edit Texts' and a few static text labels to display the results.

What I want to do is to be able to calculate from a series of numbers their: sum, average, min, max, Standard Deviation and Skewness The user will enter the following data [using Edit Text boxes]:

 Start Number of the sequence

 End Number of the sequence

 Increment step

And by using a Pushbutton all the above results will be returned in separate static texts.

I am very new to MATLAB can anyone push me into the direction i need to go inorder to achieve this.

My user interface if any help:

enter image description here

Tacit
  • 890
  • 6
  • 17
  • 42
  • Tacit, what is your question? – HebeleHododo Feb 04 '13 at 11:44
  • @HebeleHododo I am very new to MATLAB can anyone push me into the direction i need to go inorder to achieve this. – Tacit Feb 04 '13 at 11:47
  • 1
    Hello Tacit I don't really understand your problem. All of this is to me pretty straight forward so I'm not sure where you'd block in the code. If it concerns the series of numbers, check what "str2double" and "eval" functions do. – hyamanieu Feb 04 '13 at 11:47
  • 1
    Tacit, you need to write callback functions for your editboxes (where you will use `str2double` as Wli mentioned) and your pushbutton (where you will calculate stuff and write the results to your static text boxes). – HebeleHododo Feb 04 '13 at 11:54
  • Eval is actually useless in this case, variable names are not user inputs. str2double is enough. good luck – hyamanieu Feb 07 '13 at 09:50

2 Answers2

2

A simple solution should be :

function pushbutton1_Callback(hObject, eventdata, handles)
%[

    startValue = str2num(get(handles.edit1,'string')) ;
    stopValue = str2num(get(handles.edit2,'string')) ;
    step = str2num(get(handles.edit3,'string')) ;

    series = startValue:step:stopValue ;

    average = mean(series) ;
    minValue = min(series) ;
    ...
    ...
    set(handles.text1,'string',average);
    set(handles.text2,'string',minValue);
    ...
%]

Hope it will be helpful !

Romain
  • 340
  • 1
  • 8
1

You might find these 41 complete GUI examples useful... It'll answer you these questions:

1.How do I manipulate the strings in a uicontrol? GUI_1, 2, 4, 5, 13, 14, 15, 20, 21, 22, 37

2.How do make a uicontrol invisible/visible? GUI_3, 35 (See also GUI_10 for images)

3.How do I make a multi-line edit box? GUI_4

4.How can I initialize an editbox so that the cursor is blinking at startup? GUI_4, 24, 37

5.How can I let the user of my GUI know his actions are futile (or producing no results)? GUI_5

6.How can I tell which uicontrol is selected e.g., radiobuttons? GUI_6, 8

7.How do I tell how many times a uicontrol has been activated? GUI_7, 19, 28, 32, 33

8.How do I tell which button in a buttongroup is selected? GUI_8

9.How do I let the user know a process is running in the background? GUI_9

10.How can I set an image visible/invisible? GUI_10

11.How can I use a GUI to exit a FOR loop? GUI_11

12.How can I control the mouse pointer with a GUI? GUI_12

13.How do I access the value (current position) of a slider? GUI_13, 16

14.How do I use different colored strings in a listbox? GUI_14

15.What is the difference between 'listboxtop' and 'value' in a listbox? GUI_14

16.How do I make text that can be copied but not changed? GUI_15

17.How can I allow the user of my GUI to set the range of a slider? GUI_16

18.How can I display a digital clock in my GUI? GUI_17

19.How can I use a timer in a GUI? GUI_17

20.How do I use the buttondownfcn on an axes object? GUI_18, 28

21.How do I make a callback talk to another callback? GUI_19

22.How can I get the string from a popup or listbox? GUI_14, 20, 21, 22, 31, 32, 33

23.How can I set the string in a popup or listbox? GUI_21, 22

24.How can I add to the string in a popup or listbox? GUI_22

25.How do I tell which figure/axes was current before my callback executed? GUI_23

26.How do I get data from another GUI? GUI_24

27.How do I make a GUI to open image files only? GUI_25

28.How can I make popup choices mutually exclusive? GUI_26

29.How can I show the current pointer location in axes coordinates? GUI_27

30.How can I use uicontextmenus? GUI_28, 33, 39

31.How do I make my GUI control an axes in another figure? GUI_29, 30

32.What are callback strings? GUI_30

33.How can I make it so that when one of the figures closes, they all close? GUI_24, 29, 30, 41

34.How do I make several uicontrols interact in a more complicated GUI? GUI_31, 32, 33, 41

35.How do I get data from a GUI to the base workspace? GUI_25, 32, 33, 36

36.How can I use a GUI to take a screenshot of my desktop? GUI_34

37.How do I make toggle buttons act like tabbed-panels? GUI_35

38.How do I make a custom dialog box which returns a string to the base workspace? GUI_36

39.How can I make a password editbox that has the * symbols? GUI_37

40.How can I use nested function as callbacks? GUI_11, 17, 34, 36, 37, 39, 40, 41.

41.How can I use uiwait in a GUI? GUI_11, 34, 36, 37

42.How do I use JAVA in my GUI? GUI_38

43.How do I force the figure to maintain focus between uicontrol activations? GUI_38

44.How do I save an axes as an image? GUI_39

45.How can I make a simple drawing program? GUI_39

46.How can I set a button's background to match an image? GUI_40

47.How can I save the state of a system of GUIs to use later? GUI_41

bla
  • 25,846
  • 10
  • 70
  • 101