フィルターのクリア

How to add imagesc plot to an app?

63 ビュー (過去 30 日間)
JeanN
JeanN 2022 年 4 月 6 日
コメント済み: Xu-Jie Wang 2023 年 8 月 16 日
Hi all,
I am trying to put an image created from the imagesc function to display on an Matlab app.
I am struggling with that and am not sure what to do next.
I have already looked at and tried :
First, I am not sure if I should be hosting the image as as UIAxes or as an Image. I am generating the plot programaticaly from Matlab.
Let's say that I try to host it as UIAxes component ( have several plot areas in my app). That component is called UIAxes and is inside a panel. Then what I do is to put the following inside a function which I then call from the startup Function:
app.UIAxes = imagesc(R);
where R is a matrix with numbers.
I get the following error
Error using app2/startupFcn (line 98)
Error setting property 'UIAxes' of class 'app2'. Value must be of type matlab.ui.control.UIAxes or be convertible to matlab.ui.control.UIAxes.
Would anybody have an idea of what I can do here?
  2 件のコメント
DGM
DGM 2022 年 4 月 6 日
編集済み: DGM 2022 年 4 月 6 日
I don't really ever do much with the app stuff, so I'm not going to make an answer out of this. Generally, image objects, like any plot object, are children of axes objects. So instead of assigning like that, you'd call image() with the handle of the axes that is to be it's put in:
imageobjecthandle = imagesc(axeshandle,myimage);
How you manage the axes and image handles is up to you.
Brian
Brian 2023 年 1 月 16 日
How did the answer from Jakub below work out? Where there any other details you discovered?
(I'm presently having the same problem tryiing to do exactly the same thing.)
Thx.

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

回答 (1 件)

Jakub Devera
Jakub Devera 2022 年 4 月 7 日
imagesc(ax,___) creates the image in the axes specified by ax instead of in the current axes (gca). Specify the axes as the first input argument.
So you can write
imagesc(app.UIAxes, R);
or save it to a handle if you want to work with it later
app.ImageHandle = imagesc(app.UIAxes, R);
but you will have to define ImageHandle in properties of your app.
  1 件のコメント
Xu-Jie Wang
Xu-Jie Wang 2023 年 8 月 16 日
Thanks, you help me a lot.

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by