简体   繁体   English

Matlab GUI:从外部应用程序获取图形并将其显示在GUI中

[英]Matlab GUI : Get a figure from an external application and show it in the GUI

First of all thanks by advance and sorry for my bad English it is not my native tongue. 首先,首先要感谢,并为我的英语不好对不起,这不是我的母语。

My level in MATLAB Gui is zero, but i need to make a simple application. 我在MATLAB Gui中的等级为零,但是我需要做一个简单的应用程序。

So i made the GUI with the built-in assistant. 因此,我使用内置助手制作了GUI。 I have a slider which go from 0 to 1 and a button 'Update'. 我有一个从0到1的滑块和一个“更新”按钮。 The goal is when you click on the button it get the value from the slider, send it to a function already made, get the figure returned by the function and show it in the GUI. 目的是当您单击按钮时,它会从滑块获取值,将其发送到已完成的功能,获取该功能返回的图形并在GUI中显示。

My function already have fh=figure in it and return it (as an output). 我的函数中已经有fh = figure并将其返回(作为输出)。

Here is a simplified version of the function : 这是该函数的简化版本:

    function fh = draw_something_2d(P,t)
    fh=figure
    hold on;
    %some treatment and a lot of plotting
    xlabel('Axe x')
    ylabel('Axe Y')
    zlabel('Axe Z')
    title('Title Of Things')
    hold off;

And my items have this tags : the button is named :button_maj and the slider : slider 我的项目具有此标签:按钮名为:button_maj,而滑块名为:slide

Anyway i'm working on MATLAB R2014a. 无论如何,我正在使用MATLAB R2014a。

Can anybody help? 有人可以帮忙吗?

Thanks 谢谢

EDIT By built-in assistant i mean the "GUIDE" assistant. 编辑内置助手是指“ GUIDE”助手。

When i click the push button i want the figure which is made by an exterior function to show in my GUI. 当我单击按钮时,我希望由外部功能制作的图形显示在我的GUI中。 In pseudo code it would be something like 在伪代码中,它将类似于

    On_Click_PushButton{
     axe1.graphic=draw_something_2d(15,slider.getvalue());
    }

Well i was not able to find a clean solution so i copy-pasted my code and accessed directly from the "on click" function. 好吧,我找不到一个干净的解决方案,所以我复制粘贴了我的代码,并直接从“单击”功能访问。 From within i was able to access directly a figure named "axe1" as standard matlab example show. 从内部,我可以直接访问一个名为“ axe1”的图形,如标准Matlab示例所示。 It is not a clean solution but it is one. 这不是一个干净的解决方案,而是一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM