HOW PLOT LISTBOX SELECTION

4 Ansichten (letzte 30 Tage)
Krystina
Krystina am 24 Aug. 2012
I have a list box with a number of different options to plot (e.g. Fx, Fy, Mz). When one is selected, I want to plot the related variable which is stored in the workspace on the axes (axes1_graph) that i have on my GUI. How can this be achievied?
Thank you

Antworten (1)

Jan
Jan am 24 Aug. 2012
What exactly does "stored in the workspace" mean? Which workspace? Any function has its own one. It would be smarter and safer to store the data in the UserData of the figure or the listbox itself.
How do you "select" values of a listbox? Do you mean a popup menu? If so, did you search in this forum already, where this topic has been discussed dozens of times? Did you check Matt's examples already?
  3 Kommentare
Jan
Jan am 24 Aug. 2012
Bearbeitet: Jan am 24 Aug. 2012
@Krystina: Of course I'm able to guess the details, but it would be more efficient, if you provide the complete information. Where did you define the variable? Inside a function, a script or in the base workspace (such that you can display them in the command window)? How do you "select" a value of a listbox? Single click, double click, slect with the mouse and press a "Display" button?
Guessing the details of a question causes differences between the given and the needed answer. Please be as precise as possible. E.g. posting a piece of code, which reproduces the problem, is always a good idea. It might matter, if your GUI has been created programatically or using GUIDE. Explaining details like "axes1_graph" is recommended also: The meaning might be obvious for you, and it might be possible to guess what this string could be, but a good question does either define or omit such details. Thanks.
Krystina
Krystina am 24 Aug. 2012
the variables in the list are defined in the editor, using values which are imported from an excel sheet. An example is as such: Fx(i,j) = (D*sin(C*atan(B*X1-E*(B*X1-atan(B*X1)))))+Sv;
I used GUIDE to create the GUI. To select something from the listbox you single click it and it highlights.
The automatic code generated for the list box is as such:
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
if ispc && isequal(get(hObject,'BackgroundColor'), get
(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
axes_graph1 is the tag for my axes in my gui.
hope this helps.
thanks for your time

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by