GUI programming of nodes and dijkstra algorithm

hello guys i reallllyyyy need help with my project because its due 18 of this month which is after 2 days i made a GUI for this programming of dijikstra algorithm which calculates the shortest path available in the nodes the problem is when i enter the values and choose the type from the buttons the result is zero(0) like its not calculating it , but when i give values manually in the programming it gives the correct one ! so please if anyone can help me correct it , i attached both the gui and the programming files if anyone can review it thanks in advance

3 comentarios

Geoff Hayes
Geoff Hayes el 15 de Mayo de 2016
Uchiha - how is the GUI used? The app crashes as soon as I select any of the types (since I don't have any of the images). What is the workflow - select a type, select a source, select a destination, and then press Calculate?
Uchiha Duhoky
Uchiha Duhoky el 15 de Mayo de 2016
opss i forgot to attach the pics , i did now exactly thats the flow
Uchiha Duhoky
Uchiha Duhoky el 16 de Mayo de 2016
@Geoff did you find any errors in it ?

Iniciar sesión para comentar.

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 17 de Mayo de 2016
Uchiha - one problem is the use of global variables. If you put a breakpoint in the pushbutton1_Callback and run your app, you will notice that when the debugger pauses in this function and you start stepping through the code, the TYPE variable is empty. While you set this local variable in the checkbox callbacks, they are local variables only and so updating them has no effect on the global variable.
Instead of using global variables, I would use the handles structure to store this user-defined data. For example, in your checkbox callback do
function checkbox1_Callback(hObject, eventdata, handles)
ab=get(hObject,'Value');
if ab==1
handles.TYPE=2; % update the structure
guidata(hObject,handles); % save the changed structure
ab=imread('2.jpg');
axes(handles.axes1);
imshow(ab)
end
Then, in your start button callback, you would do
function pushbutton1_Callback(hObject, eventdata, handles)
if isfield(handles, 'TYPE')
TYPE = handles.TYPE;
% etc.
end
That will fix one problem, but you may have similar issues with the other global variables. Try implementing this fix and then use the debugger to see what else may be going on.

2 comentarios

Uchiha Duhoky
Uchiha Duhoky el 18 de Mayo de 2016
omgggg thank you very much man , i really appreciate it i just removed all global's in there and implemented that fix which completely fixed everything and now its working saved my ass :)
Geoff Hayes
Geoff Hayes el 18 de Mayo de 2016
Glad it worked out, Uchiha!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Mayo de 2016

Comentada:

el 18 de Mayo de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by