Question

I have program.m file that contains:

for i=1:k
  V=geAllThreeElements(n);
  fprintf('total is %d\n',size(V,1));
end

and I have tst.fig that contain Push Button that call program function and listox

I want print ('total is %d\n',size(V,1)) in list box not in command windows during program function execution, How?

Thanks

Was it helpful?

Solution

If I got you right, you are calling a m-file (script) from a pushbutton within a figure.

First of all you should return the Data of the variable you called "V". If you dont use programm.m as a function and you totally dont want to do that, you have to get "V" by loading it into your the workspace of your GUI.

See assignin for example!

now that you have the Data of V, you can use it to display information about it within a listbox like this:

%you have to know the handle of the listbox-> I call it myLB:
%if you want to append data:    
myData = get(myLB, String)
set(myLB, String, [myData sprintf('total is %d\n',size(V,1))])
%if you want to replace data:
set(myLB, String, sprintf('total is %d\n',size(V,1)))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top