⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cylinder.m

📁 通过matlab图形进行欧拉角的演示
💻 M
字号:
function [hCylinder,hPlate1,hPlate2] = Cylinder( orgin,r,h,dir,n,closed )% This Function plots a cylinder at specified orgin, with specified radius, height, direction(axis), no of points along the circumference% %   Typical Call Cylinder( orgin,r,h,dir,n ), Note: there is a matlab function "cylinder"% %   orgin: vector of order 3 x 1 specifies orgin%   h    : Height of the Cylinder%   dir  : String to specify axis of extrution 'x' or 'y' or 'z' (Only along these axes...!)%   n    : no of points along the circumference% % Typical Inputs% orgin=[0 0 -5];% r=8;% h=10;% dir='z';% n=25;% closed='closed';t=linspace(0,2*pi,n)';x1=r*cos(t);x2=r*sin(t);if dir=='y'    xx1=[[x1;x1(1)] [x1;x1(1)]]+orgin(1);    xx2=[repmat(orgin(2),length(x1)+1,1) repmat(orgin(2)+h,length(x1)+1,1)];    xx3=[[x2;x2(1)] [x2;x2(1)]]+orgin(3);elseif dir =='x'    xx1=[repmat(orgin(1),length(x1)+1,1) repmat(orgin(1)+h,length(x1)+1,1)];    xx2=[[x1;x1(1)] [x1;x1(1)]]+orgin(2);    xx3=[[x2;x2(1)] [x2;x2(1)]]+orgin(3);elseif dir =='z'    xx1=[[x1;x1(1)] [x1;x1(1)]]+orgin(1);    xx2=[[x2;x2(1)] [x2;x2(1)]]+orgin(2);    xx3=[repmat(orgin(3),length(x1)+1,1) repmat(orgin(3)+h,length(x1)+1,1)];endhCylinder=surf(xx1,xx2,xx3,repmat(3,size(xx1)));if strcmp(closed,'closed')==1    hold on    hPlate1=fill3(xx1(:,1),xx2(:,1),xx3(:,1),[0.5020    0.5020    0.5020]);    hPlate2=fill3(xx1(:,2),xx2(:,2),xx3(:,2),[0.5020    0.5020    0.5020]);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -