How to use eval and disable the edit box or drop down?

2 ビュー (過去 30 日間)
raghavendra kandukuri
raghavendra kandukuri 2019 年 5 月 21 日
HI,
can we use eval, and disable the dropdown or edit box? for example:
the below code can visit 16 fields(editboxes) and set the value coming frim G_PB, similarly i would like to do for disableing
Thanks in Advance
for i=1:16
eval(['set(handles.PwrBlg' num2str(i) ',''String'',G_PB)']);
end

採用された回答

Stephen23
Stephen23 2019 年 5 月 21 日
Do NOT use eval for trivial code like this!
Much better is to read the documentation on dynamic fieldnames:
For your code, something like this:
fld = sprintf('PwrBlg%d',i);
set(handles.(fld),'String',G_PB)
  1 件のコメント
raghavendra kandukuri
raghavendra kandukuri 2019 年 5 月 21 日
Thank you@ stephen

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

その他の回答 (0 件)

カテゴリ

Find more on Software Development Tools in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by