Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 如何通过simulink调用S函数在GUI轴上显示图形输出_User Interface_Simulink - Fatal编程技术网

User interface 如何通过simulink调用S函数在GUI轴上显示图形输出

User interface 如何通过simulink调用S函数在GUI轴上显示图形输出,user-interface,simulink,User Interface,Simulink,我有一个simulink模型,它接受作为增量和时间的输入 此simulink块调用另一个名为“plotstatevariables.m”的m文件 function plotStateVariables(uu) % % process inputs to function delta_e = 180/pi*uu(1); % elevator angle (degrees) delta_a = 180/pi*uu(2); % ai

我有一个simulink模型,它接受作为增量和时间的输入

此simulink块调用另一个名为“plotstatevariables.m”的m文件

    function plotStateVariables(uu) % 

    % process inputs to function

    delta_e     = 180/pi*uu(1);     % elevator angle (degrees)
    delta_a     = 180/pi*uu(2);     % aileron angle (degrees)
    delta_r     = 180/pi*uu(3);     % rudder angle (degrees)
    delta_t     = uu(4);            % throttle setting (unitless)
    t           = uu(5);            % simulation time

    % define persistent variables 

    persistent delta_e_handle
    persistent delta_a_handle
    persistent delta_r_handle
    persistent delta_t_handle

% first time function is called, initialize plot and persistent vars
  if t==0,
      figure(2), clf

        subplot(2,2,1)
        hold on
        delta_e_handle = graph_y(t, delta_e, [], 'b');
        ylabel('\delta_e')

        subplot(2,2,2)
        hold on
        delta_a_handle = graph_y(t, delta_a, [], 'b');
        ylabel('\delta_a')

        subplot(2,2,3)
        hold on
        delta_r_handle = graph_y(t, delta_r, [], 'b');
        ylabel('\delta_r')

        subplot(2,2,4)
        hold on
        delta_t_handle = graph_y(t, delta_t, [], 'b');
        ylabel('\delta_t')

    % at every other time step, redraw state variables
    else 

       graph_y(t, delta_e, delta_e_handle);
       graph_y(t, delta_a, delta_a_handle);
       graph_y(t, delta_r, delta_r_handle);
       graph_y(t, delta_t, delta_t_handle);
    end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % graph y with lable mylabel function handle = graph_y(t, y, handle, color)

if isempty(handle),
  handle    = plot(t,y,color);
else
  set(handle,'Xdata',[get(handle,'Xdata'),t]);
  set(handle,'Ydata',[get(handle,'Ydata'),y]);
  %drawnow
end

% %============================================================================= % sat % saturates the input between high and low %============================================================================= % function out=sat(in, low, high)

if in < low,
    out = low;
elseif in > high,
    out = high;
else
    out = in;
end
“plotstatevariables.m”使用此输入绘制图2,如代码所示。我想在另一个GUI轴中显示此图

如何将此图传递给“plotstatevariables.m”的GUI轴代码

    function plotStateVariables(uu) % 

    % process inputs to function

    delta_e     = 180/pi*uu(1);     % elevator angle (degrees)
    delta_a     = 180/pi*uu(2);     % aileron angle (degrees)
    delta_r     = 180/pi*uu(3);     % rudder angle (degrees)
    delta_t     = uu(4);            % throttle setting (unitless)
    t           = uu(5);            % simulation time

    % define persistent variables 

    persistent delta_e_handle
    persistent delta_a_handle
    persistent delta_r_handle
    persistent delta_t_handle

% first time function is called, initialize plot and persistent vars
  if t==0,
      figure(2), clf

        subplot(2,2,1)
        hold on
        delta_e_handle = graph_y(t, delta_e, [], 'b');
        ylabel('\delta_e')

        subplot(2,2,2)
        hold on
        delta_a_handle = graph_y(t, delta_a, [], 'b');
        ylabel('\delta_a')

        subplot(2,2,3)
        hold on
        delta_r_handle = graph_y(t, delta_r, [], 'b');
        ylabel('\delta_r')

        subplot(2,2,4)
        hold on
        delta_t_handle = graph_y(t, delta_t, [], 'b');
        ylabel('\delta_t')

    % at every other time step, redraw state variables
    else 

       graph_y(t, delta_e, delta_e_handle);
       graph_y(t, delta_a, delta_a_handle);
       graph_y(t, delta_r, delta_r_handle);
       graph_y(t, delta_t, delta_t_handle);
    end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % graph y with lable mylabel function handle = graph_y(t, y, handle, color)

if isempty(handle),
  handle    = plot(t,y,color);
else
  set(handle,'Xdata',[get(handle,'Xdata'),t]);
  set(handle,'Ydata',[get(handle,'Ydata'),y]);
  %drawnow
end

% %============================================================================= % sat % saturates the input between high and low %============================================================================= % function out=sat(in, low, high)

if in < low,
    out = low;
elseif in > high,
    out = high;
else
    out = in;
end
%完赛

谢谢