资源简介
matlab开发-scatter3sph。散射3SPH绘制具有不同大小和颜色的三维球体的三维散射图
![](http://www.nz998.com/pic/70788.jpg)
代码片段和文件信息
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开发-能带计算
- matlab开发-FlockingAlgorithm
- matlab开发-MuellerStokesJonesCalculus
- matlab开发-HX711的自定义数据库
- matlab开发-SMOTEBoost
- matlab开发-果蝇优化算法第二版
- matlab开发-多变量决策树
- matlab开发-水轮发电机模型
- matlab开发-交通警告标志识别标签代码
- matlab开发-RUSBoost
- matlab开发-基于遗传算法的机器人运动
- matlab开发-MPU6050加速度陀螺仪
- matlab开发-功率曲线FAsmallscalewindturbi
- matlab开发-NASAJPLDE405开发星历表
- matlab开发-SortinoRatio
- matlab开发-永磁TDC并联电机数学模型
- matlab开发-3相SPWM整流器
- matlab开发-Kilobotswarm控制Matlabarduino
- matlab开发-简单音频播放
- matlab开发-记录文件的绘图仪加速度、
- matlab开发-永磁同步电机PMSM动态数学模
- matlab开发-多目标优化差分进化算法
- matlab开发-随机微分方程解算
- matlab开发-波长调制光谱的二次谐波模
- matlab开发-仿制药生物生理学基础药动
- matlab开发-使用svmrfe选择功能
- matlab开发-KDTreeNearestNeighborandRangeSear
- matlab开发-stlread
- matlab开发-三维图像堆栈查看器
- matlab开发-动态电压恢复器故障dvr
评论
共有 条评论