Effacer les filtres
Effacer les filtres

Problem with GUI functions and obtain values from graph?

1 vue (au cours des 30 derniers jours)
Mahmoud
Mahmoud le 16 Juin 2014
Commenté : Joseph Cheng le 17 Juin 2014
Hello, I'm designing a GUI program in order to use it in a presentation, the GUI design and image is included as an attachment, also the graphs to be plotted are included. I want to calculate the value of S which is equals to (S=u0*u1*q*B/E). Where q, B and E are values entered by the user; u0 and u1 are two values that are obtained from a graph. u0 depends on D/B and u1 depends on H/B and L/B; where H and L are values entered by the user. So basically I want to enter the values of q,B,H,D and E. Then the GUI has to obtain the values of u0 and u1 corresponding to the given H/B and L/B. For example if D/B=2.5 then u0=0.9 and if H/B=100 and L/B=3 then u1=1.3 and then these values will be used to calculate S. I'm new to GUI so basically I have done nothing except putting the texts and push buttons. I need someone to help me with writing the functions in order to do this and mainly in obtaining the values from the graphs. Also I need help in plotting the graphs. Any help will be appreciated, my graduation depends on this presentation. Thanks in advance.

Réponse acceptée

Joseph Cheng
Joseph Cheng le 16 Juin 2014
Putting the text and push buttons on the screen is the first step. the next step would be to generate a look-up table that you can used to get values from the graphs. Or if the graph is generated by an equation then you can insert the equation into the code to generate the values.
After that you can use the get() function to grab the values in your calculate callback function.
example: q=get(handles.editboxQ,'String'); q=str2num(q); %as editbox will be storing it as a string and not a number.
after you do that for each variable you can then do your math stuff and use the lookup table to generate your final result.
  2 commentaires
Mahmoud
Mahmoud le 17 Juin 2014
Thanks a lot, so I was able to get equations from the graph and insert the text and push buttons to the screen. However I'm finding problems in my calculate callback function. Could you explain a little more on how to use : q=get(handles.editboxQ,'String'); q=str2num(q) for other values as well.
Joseph Cheng
Joseph Cheng le 17 Juin 2014
What you can try is put a dummy line somewhere in the callback for your calculate button. something like disp('debug') which doesn't really do anything but lets you put a break point there. Click the button and it'll stop right there.
So, what i ment by q=get(handles.editboxQ,'String') is to get the variable q by getting the stuff that was entered into the q editbox.
so this can be done with the other edit boxes as well.
Generically you can see that the format of the code is
X = get(handles.(tag of the edit box),'String');
This will return what is inside the edit box and set it to X.
when you double click on the item in guide it'll bring up the property editor and there is a field called tag.
Then you have to format to the type you want, rinse and repeat for rest of the variables.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Desktop dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by