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

2 次查看(过去 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 CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by