Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
looking for a single function

Subject: looking for a single function

From: David Edson

Date: 11 Jun, 2009 10:29:02

Message: 1 of 1

I want to define a single function that gives me exactly the same as the figure defined as follows. As you can see, i have to change the value of beta twice to get what i want. Is there a way that I can define such a shape by a single function of beta and theta?

% the function

k2=-2; k3=2/30;
rx=10.5; ry=10.5; rz=10;
theta=-pi/2:pi/100:pi/2;

x=[]; y=[ ];

for i=1:2
    
beta=pi*i;
g=(ry/10)*( 2.^(k2.*theta)+ 2.^(k3.*theta));
%% x,y values

x1=rx.*cos(theta).*cos(beta);
y1=ry.*sin(theta)+g;

x=[x;x1'];
y=[y;y1'];

end

x0=mean(x);
y0=mean(y);
plot(x-x0,y-y0)
hold on
plot(x0,y0,'.y')
%mesh(x,y,z)
axis equal;
grid off;


axis ij;
axis off

thanks,

TE

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us