Hello, how can access this function in gui when i push the button?
function [sol,b]=nordest(f,cer)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
if (sum(f)~=sum(cer)),
disp('EROARE: Oferta totala este diferita fata de cererea totala.');
return;
end
m=length(f);
n=length(cer);
i=1;
j=1;
sol=zeros(m,n);
b=zeros(m,n);
while ((i<=m) & (j<=n))
if f(i)<cer(j)
sol(i,j)=f(i);
b(i,j)=1;
cer(j)=cer(j)-f(i);
i=i+1;
else
sol(i,j)=cer(j);
b(i,j)=1;
f(i)=f(i)-cer(j);
j=j+1;
end
end
end
there
.....
set(handles.text12,'String',ln);
set(handles.text13,'String',cl);
if cl~=nrcereri
msgbox('Matricea costurilor este introdusa gresit. Reluati!', 'Erroare', 'help', 'modal')
end;
[sol,b]=nordest(f,cer)
cost=[];
[sol f;cer' 0];
set(handles.uitable6,'Data',[sol f;cer' 0]);
costtotal= num2str(sum(sum(c.*sol)));
set(handles.costtotal,'String',costtotal);
.....

 Accepted Answer

Florin - you would just call this function from your pushbutton callback as
function pushbutton1_Callback(hObject, event, handles)
% get (from somewhere?) f and cer
% call your function
[sol,b]=nordest(f,cer)
cost=[];
[sol f;cer' 0];
% display the results
set(handles.uitable6,'Data',[sol f;cer' 0]);
costtotal= num2str(sum(sum(c.*sol)));
set(handles.costtotal,'String',costtotal);

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!