How can I link a scroll-bar GUI with the mathematical code I have written?
Afficher commentaires plus anciens
I am trying to write a program using GUIDE that has several scroll-bars. The program is going to plot a interference pattern of two point-sources of light varying certain variables using the scroll-bars. I have the math part of the code working and have some sort of the GUI as well. However, I cannot seem to get the two working together. The scroll-bars wont seem to vary the math part of the code.
If anybody could give me any advice I would greatly appreciate it.
1 commentaire
Nicholas
le 19 Nov 2012
I'm not exactly sure what your question here is, however I can tell you that by default the sliders update only when the mouse button is released. A few weeks ago, though, I found some code on here that added "real time sliders". I can't find the exact link right now, but I have the code that I used.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
obj = get(YOURMAINFIGUREWINDOW, 'CurrentObject');
if ~isempty(obj)
if obj == YOURSLIDERHANDLE
set(YOURSLIDERHANDLE, 'Value', round(num2str(get(YOURSLIDERHANDLE, 'Value')) / 5)* 5 ) ); %%I was rounding the value here
set(SOMEDISPLAYHANDLE, 'String', num2str(get(YOURSLIDERHANDLE, 'Value'))); %%This line sets the handle value to an output
end
end
What this does is find which object your mouse is hovering over, and if it's a slider, it replaces a display value with that number. Instead of replacing a display value, you could perform a math function.
This should work, if not, I apologize as I'm not really a qualified expert.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Read, Write, and Modify Image dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!