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 件のコメント

Geoff Hayes
Geoff Hayes 2016 年 5 月 15 日
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 2016 年 5 月 15 日
opss i forgot to attach the pics , i did now exactly thats the flow
Uchiha Duhoky
Uchiha Duhoky 2016 年 5 月 16 日
@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 件のコメント

Uchiha Duhoky
Uchiha Duhoky 2016 年 5 月 18 日
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 2016 年 5 月 18 日
Glad it worked out, Uchiha!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by