how to change the value of a gui object using an external function (i.e without using the m file associated with the gui)?

1 回表示 (過去 30 日間)
Hello there,
The question is quite self-explanatory so i'll just add an example to make it clearer:
function [csnames] = editcs (value)
global CSPROPS
CSinterface(); *%%this initiates the GUI*
global matprops
% reset materials
matnames = cell(length(CSPROPS(value).matprops),1);
for m = 1:length(CSPROPS(value).matprops)
matnames(m) = {CSPROPS(value).matprops(m).name};
end
set(handles.list_materials,'String',matnames);
%%here is where i am getting my error, which i find is probably due to any syntax error when calling out what handles.list_materials refers to.
Would really appreciate if anyone could give me an insight on this.
PN.
  1 件のコメント
Jan
Jan 2012 年 11 月 8 日
No, the question is definitively not self-explanatory. You assume a syntax error, but you do not mention the occurring error message or MLint warning. If there is no such message, why do you think, that it is probably a syntax error?
Btw.: This is more efficient:
matnames{m} = CSPROPS(value).matprops(m).name;
By this way Matlab does not have to create a cell array on the right hand side at first, but can insert the value directly in the existing cell on teh left hand side.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 8 日
Was the GUI made with GUIDE? If so then
guihandle = CSinterface();
handles.list_materials = findobj(guihandle, 'tag', 'list_materials');

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by