duplicate tab:how know reference object?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
obj = allchild(app.Tab_X);
newtab = uitab(app.TabGroup,'Title',"XX"); % Create a new tab with the same title
copyobj(obj,newtab);
but what is the reference this object?
I don't think they have the same name as the original' ...

example: in this example i duplicate chart in other tab..but how can i know the referenze this Axis?
1 件のコメント
i find this solution:
h=findobj(newtab)
h =
9×1 graphics array:
Tab (CL)
GridLayout
UIAxes (Equity)
UIAxes (Equity)
UIAxes (Equity)
UIAxes (Equity)
Label (gg Vis)
NumericEditField (250)
Button (DRAW)
h(3) is the reference axis
or esist better method to catch it?
採用された回答
Voss
2023 年 10 月 23 日
Better than findobj() is to capture the output from copyobj():
new_obj = copyobj(obj,newtab);
12 件のコメント
ok but if i wnt to catch reference to axis (in my example is h(3)
how can i do it?
this is your new_obj..(is tab in the pics)
How can i catch reference of uiaxis? (4 axis)

Voss
2023 年 10 月 24 日
Do it the same way you would've done it wih the output of findobj() I guess
ax = new_obj(strcmp(get(new_obj,'Type'),'axes'))
piero
2023 年 10 月 24 日
thanks..
last question: How can I distinguish 2 objects that are called the same?
Example: uinumericeditfield ..(there are two)

Voss
2023 年 10 月 24 日
That's a good question. The best way would be to create each object individually, rather than using copyobj to copy everything in the tab, storing the new objects as appropriately-named app properties (perhaps appending each to an array of similar objects).
For example:
% suppose you have an array of editfields already created, called app.editfields
% copy the first one to newtab:
app.editfields(end+1) = copyobj(app.editfields(1), newtab);
Similarly for any other object you want to copy and keep track of.
piero
2023 年 10 月 24 日
thank
Voss
2023 年 10 月 24 日
yw
it's so difficult :((
newtab = uitab(app.TabGroup_Instrum,'Title',cat(i)); % Create a new tab with the same title
copyobj(obj,newtab);
ef = uieditfield(newtab,"numeric")
ef.Value=30;
copyobj(ef, newtab);
h=findobj(newtab);
h
end

two problem :
1) it didn't replace the editfields but added others
2)it added 2 for me even though I only added 1
Voss
2023 年 10 月 24 日
You created two edit fields in newtab
% create an edit field in newtab:
ef = uieditfield(newtab,"numeric")
% copy that ef to newtab:
copyobj(ef, newtab);
Voss
2023 年 10 月 24 日
The solution, as I said, is not to use findobj() but to store things in a methodical fashion.
If you're going to use copyobj(), then capture its output, as I showed before.
hi,,,,, I have another small obstacle
i've selected "Fdax" tab.....i press "DRAW"...how can i call a function with callback method? ..
If I were in "aggregate" it would call the "callback" function and the problem would not exist
the variable :bb(n) is the arrayreference of the 6 button "Draw"

Voss
2023 年 10 月 25 日
So you have 6 Draw buttons and you need to make each one do something different, is that right?
(Option 1) When you create each Draw button (e.g., by copyobj) set the new button's callback to an appropriate function.
(Option 2) Alternatively, have each Draw button execute the same callback and figure out what to do inside that callback, based on which tab contains the Draw button whose callback is currently executing.
Option 1:
newobj = copyobj(allchild(tab),newtab);
newdrawbutton = % figure out which element of newobj is the new Draw button
switch newtab
case app.FDAXtab % handle to a tab
newdrawbutton.ButtonPushedFcn = @callback_for_FDAX_draw;
case app.Aggregatetab % handle to another tab
newdrawbutton.ButtonPushedFcn = @callback_for_Aggregate_draw;
case % etc.
% ...
end
Option 2:
function draw_button_callback(app,evt)
switch get(gcbo,'Parent')
case app.FDAXtab % handle to a tab
% code for what should be done when Draw button
% in FDAX tab is pushed goes here
case app.Aggregatetab % handle to another tab
% code for what should be done when Draw button
% in Aggregate tab is pushed goes here
case % etc.
% ...
end
end
piero
2023 年 10 月 25 日
thx
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Code Execution についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
