Servlets 使用matlab生产服务器(MPS)和webfigure

Servlets 使用matlab生产服务器(MPS)和webfigure,servlets,matlab-deployment,Servlets,Matlab Deployment,我想知道如何从matlab中传递一个绘图,在servlet页面上显示为webfigure。请注意,我使用的是MPS。因此,我不是将matlab代码打包到java中,而是使用matlab函数的客户端代理 我的eg matlab函数: function varargout = mymagicplot(in,displayPlot) x = magic(in); varargout{1} = x; if (strcmp(displayPlot, 'Plot'))

我想知道如何从matlab中传递一个绘图,在servlet页面上显示为webfigure。请注意,我使用的是MPS。因此,我不是将matlab代码打包到java中,而是使用matlab函数的客户端代理

我的eg matlab函数:

function varargout = mymagicplot(in,displayPlot)
    x = magic(in);
    varargout{1} = x;
    if (strcmp(displayPlot, 'Plot'))
       varargout{2} = {plot(x)};
end
在servlet方面:

interface MatlabMagic {
  public Object[] mymagicplot(int num_outargs, int size, String plotOption) throws IOException, MATLABException;
}

问题是如何将绘图显示编码为servlet页面上的webfigure?

我尝试了一种解决方法,将matlab代码拆分为两个函数

第一个函数由客户端代理使用

function m = mymagic(in)
    m = magic(in);
end
第二个函数由库编译器打包到java类中

function returnfigure = mygetwebfiguremagicplot(in)
   h = figure;
   set(h, 'Visible', 'off');
   plot(in);
   returnfigure = webfigure(h);
   close(h);
end
通过这种方式,我可以访问MPS中的mymagic函数.ctf,将结果返回到servlet,并使用第二个函数matlab代码创建的java类将其绘制为webfigure

这只是我能想到的一个可行的解决方案