matlab调用jmathplot的jar方法

jmathtool是一个非常不错的开源jar用 三维,二维等 绘图的java工具包。下面举例说明如何在matlab 调用jmathtool的绘图方法而并非使用matlab自带的绘图工具。一下就以三维,二维绘图类为例:
下面是编写的j plot.m

function cmdtest=jplot(data,varargin)
% Usage: jplot.<sh|bat> <-2D|-3D> [-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>]
% [options] <ASCII file (n rows, m columns)> [[options] other ASCII
% file][-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>] giving the legend
% position[options] are:
% -t <SCATTER|LINE|BAR|HISTOGRAM2D(<integer h>)|HISTOGRAM3D(<integer h>,
% <integer k>)|GRID3D|CLOUD2D(<integer h>,<integer k>)|CLOUD3D(
% <integer h>,<integer k>,<integer l>)> type of the plot
% SCATTER|LINE|BAR: each line of the ASCII file contains coordinates
% of one point.
% HISTOGRAM2D(<integer h>): ASCII file contains the 1D sample (i.e.
% m=1) to split in h slices.
% HISTOGRAM3D(<integer h>,<integer k>): ASCII file contains the 2D
% sample (i.e. m=2) to split in h*k slices (h slices on X axis and k
% slices on Y axis).
% GRID3D: ASCII file is a matrix, first row gives n X grid values,
% first column gives m Y grid values, other values are Z values.
% CLOUD2D(<integer h>,<integer k>): ASCII file contains the 2D sample
% (i.e. m=2) to split in h*k slices (h slices on X axis and k slices
% on Y axis), density of cloud corresponds to frequency of X-Y slice
% in given 2D sample.
% CLOUD3D(<integer h>,<integer k>,<integer l>): ASCII file contains
% the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X
% axis, k slices on Y axis, l slices on Y axis), density of cloud
% corresponds to frequency of X-Y-Z slice in given 3D sample.
% -n name name of the plot
% -v <ASCII file (n,3|2)> vector data to add to the plot
% -q<X|Y|Z>(<float Q>) <ASCII file (n,1)> Q-quantile to add to the
% plot on <X|Y|Z> axis. Each line of the given ASCII file contains the
% value of quantile for probvability Q.
% -qP<X|Y|Z> <ASCII file (n,p)> p-quantiles density to add to the plot
% on <X|Y|Z> axis. Each line of the given ASCII file contains p values.
% -qN<X|Y|Z> <ASCII file (n,1)> Gaussian density to add to the plot on
% <X|Y|Z> axis. Each line of the given ASCII file contains a
% standard deviation.

% Sqniu 09/24/09
% Modified:
% $Revision:0.1 $Date: 2009/09/24 11:05:56 $
%--------------------------------------------------------------------------
if nargin < 1
    error('MATLAB:jplot:Nargin','Requires at least 1 input arguments.');
end
[row,col]=size(data);
if col==2
    basestr='java -cp jmathplot.jar org.math.plot.PlotPanel -2D -l SOUTH ';
elseif col==3
    basestr='java -cp jmathplot.jar org.math.plot.PlotPanel -3D -l SOUTH ';
else
    error('MATLAB:jplot:data',' The matrix with two columns or three columns.');
end

filetemp=['jplot','.txt'];

disp(varargin)
if length(varargin)<1
    dlmwrite(filetemp,data,'delimiter',' ','newline','pc');
    runstr=[basestr,filetemp];
elseif length(varargin)>=1
    varargin=strcat(' ',varargin);
    drawflag=cell2mat(varargin);
    dlmwrite(filetemp,data,'delimiter',' ','newline','pc');
    runstr=[basestr,drawflag,' ',filetemp];
else
    error('MATLAB:jplot:varargin','Input arguments is not right.');
end
disp(runstr)
cmdtest=dos(runstr);
delete(filetemp);
end

 
例图:
>>jplot(rand(10,2),'-t line',' -n data')



>>jplot(rand(10,3),'-t bar',' -n data')


>>jplot(rand(10,3))



需要的资源jmathplot.jar 该jar包已经上传 须将该 文件下载改名为jmathplot.jar即可用。将jar和上面的jplot. m文件放在同一个文件夹下,并将 运行路径置于该文件夹路径。然后可以按照上图所示例子在matlab 命令窗口调用,也可在其他m文件中调用。jplot.m的调用接口已经规范化为matlab的格式。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值