필터 지우기
필터 지우기

Creating a 3d Helix Spiral with Surf command

조회 수: 39 (최근 30일)
ArMalik
ArMalik 2021년 4월 27일
이동: DGM 2023년 3월 13일
Hello Matlab family,
I am struck with this code in which I am unable to create a right 3d helical plot. Can you guys help me in identifying the problem

채택된 답변

DGM
DGM 2021년 4월 28일
Hey, someone got results!
The remaining problems are few:
clc; clf
p=0.199;% Pitch distance
a=0.02999500;% Radius of the helis wire
b=0.191; %Radius of the helix
n = 5; %is the number of turns.
del = atan(p/(2*pi*b));
u=linspace(0, 2*pi, 10); % correct range, practical number of points
v=linspace(0, 2*pi*n, 300); % practical number of points
[u,v]=meshgrid(u,v);
x1 = b + a*cos(u); % u, not delta
x2 = -a*sin(u)*sin(del);
x = (x1.*sin(v))+(x2.*cos(v)); % elementwise mult
y =(-x1.*cos(v))+(x2.*sin(v)); % elementwise mult
z = ((p*v)/(2*pi))+(a*sin(u)*cos(del));
h=surf(x, y, z);
title('3D Image of Helix')
zlabel('Height')
axis equal % otherwise it gets stretched out
% make it fancy
axis off
shading flat
lightangle(-90,30)
h.FaceLighting = 'gouraud';
h.SpecularStrength = 0.5;
h.AmbientStrength = 0.3;
h.DiffuseStrength = 0.9;
  댓글 수: 3
Ar
Ar 2023년 3월 12일
이동: DGM 2023년 3월 13일
Cool!
How to make black background?
DGM
DGM 2023년 3월 13일
이동: DGM 2023년 3월 13일
This is the code I used:
% set custom colormap
cset = ccmap('pastel',128);
colormap(cset)
bgc = 0; % background gray level
oc = get(gcf,'color'); % remember current background
set(gcf,'color',[1 1 1]*bgc) % set new background
% get screenshot and add padding
hires = addborder(export_fig('-a4','-m2'),[80 120],bgc*255);
set(gcf,'color',oc) % reset original figure background
Though note that this uses third party tools:
Also note that I did this in R2015b with an older version of export_fig(). You may find that it doesn't render exactly the same in different environments.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by