how to connect a GUI to a program

2 views (last 30 days)
Maroua BEKKAR
Maroua BEKKAR on 11 Sep 2020
Edited: Mario Malic on 12 Sep 2020
Hello,
I am working on a program which resolve transportation problem and a GUI for this program.
the user will enter n : numbber of sources , m : number of distinations , demand of each distination ,the supply for each source and costs , and the program will calculate a matrix A ,, a vector b using demand and supply and a vector c using costs , and i will use the function Linprog on A,b,c to calculate the optimal solution .i have the program, i made a GUI where the user can enter all those data but i don't know how to connect between them , i wish if there's a method to use the program directly , or if there's not i wish someone can help me .
  6 Comments
Mario Malic
Mario Malic on 12 Sep 2020
Edited: Mario Malic on 12 Sep 2020
Explain "the program", what is it, is it a MATLAB script/function or something completely different?

Sign in to comment.

Answers (1)

Mario Malic
Mario Malic on 12 Sep 2020
Edited: Mario Malic on 12 Sep 2020
Now that I know that it's a script, I can answer the question.
I assume you're using GUIDE, unfortunately I have never used it, but idea is the same.
Create a button in the program, and make a callback for the button that runs the function with input arguments, or pass the whole application. In second case, define your variables as public properties so you can access them in TheProgram function.
% Callback for button clicked (I am not sure if callback written correctly)
function ButtonClicked(app,event)
TheProgram(app)
% or
% TheProgram(app.var1, app.var2, app.var3)
end
Function
% In your function if you passed the app
function TheProgram(app)
app.var1
app.var2
end
% If you pass variables
function TheProgram(var1, var2, var3)
% the code
end

Categories

Find more on File Operations in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!