Why I cannot "set" what I got with "get"?

조회 수: 1 (최근 30일)
Csaba
Csaba 2020년 8월 15일
댓글: Walter Roberson 2020년 8월 16일
I have the following code:
hfig=figure(1);
clf;
c(1) = uicontrol(hfig...
,'Style','text'...
,'Position',[20 20 60 80]...
,'String','text-1'...
);
c(2) = uicontrol(hfig...
,'Style','text'...
,'Position',[20 110 60 80]...
,'String','text-2'...
);
c(3) = uicontrol(hfig...
,'Style','text'...
,'Position',[20 200 60 80]...
,'String','text-3'...
);
c(4) = uicontrol(hfig...
,'Style','text'...
,'Position',[20 290 60 80]...
,'String','text-4'...
);
zz=get(c, 'String')
zz =
4×1 cell array
{'text-1'}
{'text-2'}
{'text-3'}
{'text-4'}
set(c,'String',zz)
(I have inserted the printout from Command window just for clarity).
Before issuing set command, the figure looks like this:
After issuing the set command:
Is it possible to use "set" command to set different objects' property to different value? If I set back what I got, it should be the same shouldn't it???

채택된 답변

Antonio Ciociola
Antonio Ciociola 2020년 8월 15일
Try this:
set(c,{'String'},zz);
For more information take a look to "set" reference page: Set Help
  댓글 수: 2
Csaba
Csaba 2020년 8월 16일
Thanks! I checked "set" but did not realized this feature.
Walter Roberson
Walter Roberson 2020년 8월 16일
It is obscure, and I keep having to test to re-invent it because I keep getting confused on how to work it with multiple objects and multiple properties and with different values for each.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by