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

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?
opss i forgot to attach the pics , i did now exactly thats the flow
@Geoff did you find any errors in it ?

댓글을 달려면 로그인하십시오.

 채택된 답변

Geoff Hayes
Geoff Hayes 2016년 5월 17일

0 개 추천

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

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 :)
Glad it worked out, Uchiha!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

질문:

2016년 5월 15일

댓글:

2016년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by