Can you have FunctionOne take arguments as below? When calling from inside FunctionOne, you pass two arguments, but when calling the function from outside, you call it without arguments like you were doing before.
FunctionOne (StockP,Time)
if nargin == 2
InitialPrice = StockP;
T = Time;
else
InitialPrice=str2double(get(handles.StockP,'String'));
T=str2double(get(handles.Time,'String')); %This value is maximum 20
end
TargetPrice=105;
StockPrice= InitialPrice*(1+randn) %just for simplicity
If T > 0
If StockPrice>TargetPrice
update the GUI %end
else
FunctionOne(StockPrice,T-1);
end
end
end