필터 지우기
필터 지우기

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에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by