资源简介
matlab开发-scatter3sph。散射3SPH绘制具有不同大小和颜色的三维球体的三维散射图
代码片段和文件信息
function scatter3sph(XYZvarargin)
%SCATTER3SPH (XYZ) Makes a 3d scatter plot with 3D spheres
% SCATTER3SPH is like scatter3 only drawing spheres instead
% of flat circles at coordinates specified by vectors X Y Z. All three
% vectors have to be of the same length.
% SCATTER3SPH(XYZ) draws the spheres with the default size and color.
% SCATTER3SPH(XYZ‘size‘S) draws the spheres with sizes S. If length(S)= 1
% the same size is used for all spheres.
% SCATTER3SPH(XYZ‘color‘C) draws the spheres with colors speciffied in a
% N-by-3 matrix C as RGB values.
% SCATTER3SPH(XYZ‘transp‘T) applies transparency level ‘T‘ to the spheres
% T= 0 => transparent T= 1 => opaque.
% Parameter names can be abreviated to 3 letters. For example: ‘siz‘ or
% ‘col‘. Case is irrelevant.
%
% Example
% %Coordinates
% X= 100*rand(91); Y= 100*rand(91); Z= 100*rand(91);
%
% %Colors: 3 blue 3 red and 3 green
% C= ones(31)*[0 0 1];
% C= [C;ones(31)*[1 0 0]];
% C= [C;ones(31)*[0 1 0]];
%
% %Sizes
% S= 5+10*rand(91);
%
% scatter3sph(XYZ‘size‘S‘color‘C‘trans‘0.3);
% axis vis3d
%-- Some checking...
if nargin < 3 error(‘Need at least three arguments‘); return; end
if mean([length(X)length(Y)length(Z)]) ~= length(X) error (‘Imput vectors X Y Z are of different lengths‘); return; end
%-- Defaults
C= ones(length(X)1)*[0 0 1];
S= 0.1*max([X;Y;Z])*ones(length(X)1);
nfacets= 15;
transp= 0.5;
%-- Extract optional arguments
for j= 1:2:length(varargin)
string= lower(varargin{j});
switch string(1:min(3length(string)))
case ‘siz‘
S= varargin{j+1};
if length(S) == 1
S= ones(length(X)1)*S;
elseif length(S) < length(X)
error(‘The vector of sizes must be of the same length as coordinate vectors (or 1)‘);
return
end
case ‘col‘
C= varargin{j+1};
if size(C2) < 3 error(‘Colors matrix must have 3 columns‘); return; end
if size(C1) == 1
C= ones(length(X)1)*C(1:3);
elseif size(C1) < length(X)
error(‘Colors matrix must have the same number of rows as length of coordinate vectors (or 1)‘);
return
end
case ‘fac‘
nfacets= varargin{j+1};
case ‘tra‘
transp= varargin{j+1};
otherwise
error(‘Unknown parameter name. Allowed names: ‘‘size‘‘ ‘‘color‘‘ ‘‘facets‘‘ ‘‘transparency‘‘ ‘);
end
end
%-- Sphere facets
[sxsysz]= sphere(nfacets);
%--- Correct potential distortion
maxax= max([range(X) range(Y) range(Z)]);
ratios= [range(X)/maxax range(Y)/maxax range(Z)/maxax];
sx= sx*ratios(1);
sy= sy*ratios(2);
sz= sz*ratios(3);
%-- Plot spheres
hold on
for j= 1:length(X)
surf(sx*S(j)+X(j) sy*S(j)+Y(j) sz*S(j)+Z(j)...
‘Linestyle‘‘none‘...
‘FaceColor‘C(j:)...
‘FaceAlpha‘transp);
end
daspect([ratios(1) ratios(2) ratios(3)]);
light(‘Position‘[1 1 1]‘style‘‘infinit‘‘Color‘[1 1 1]);
lighting gouraud;
view(3030)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2961 2014-10-02 18:19 scatter3sph.m
文件 1509 2014-10-02 18:19 license.txt
相关资源
-
matlab开发-单相三电平去阻尼Pwmba
s - matlab开发-TraCI4Matlab
- matlab开发-三个27电平转换器,带有单
- matlab开发-DynaSimDynaSim
- matlab开发-spy2m
- matlab开发-landmask
- matlab开发-经济调度通用算法解决方案
- matlab开发-图片加密和解密
- matlab开发-分子通讯粘着剂
- matlab开发-IEEE754二进制表示
- matlab开发-kmvcreditriskmodel违约风险概率
- matlab开发-17电平模块多电平转换器
- matlab开发-Xfoilformatlab
- matlab开发-脑瘤的分割
- matlab开发-车辆网络工具箱支持kvaser和
- matlab开发-CryoSat2DEMs
- matlab开发-BlandAltmanplot
- matlab开发-使用PSO的最佳模糊控制器
- matlab开发-电机磁轴承
- matlab开发-Treynorblackportfoliomanagement模型
- matlab开发-黑白图像增强器
- matlab开发-二维波动方程模拟
- matlab开发-ResponseSpectra
- matlab开发-huashiyiqikeLSTMMATLAB
- matlab开发-HestonOptionPricer
- matlab开发-三相电压调节器
- matlab开发-单级电液伺服阀
-
matlab开发-iau2006 acioba
sedDusingXy系列 - matlab开发-带DPWM0调制的三相逆变器
- matlab开发-Earthquakesimulation
评论
共有 条评论