0

我有 program.m 文件,其中包含:

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

我有 tst.fig 包含调用程序功能和 listox 的按钮

我想在程序函数执行期间在列表框中而不是在命令窗口中打印 ('total is %d\n',size(V,1)),如何?

谢谢

4

1 回答 1

1

如果我没听错,你就是从图中的按钮调用 m 文件(脚本)。

首先,您应该返回您称为“V”的变量的数据。如果您不使用 programm.m 作为函数并且您完全不想这样做,则必须通过将“V”加载到 GUI 的工作区中来获取它。

例如,请参见分配!

现在您有了 V 的数据,您可以使用它在列表框中显示有关它的信息,如下所示:

%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)))
于 2013-09-30T08:47:42.003 回答