简体   繁体   中英

How to plot Leminscate shape using Matlab?

How to plot this Leminscate (−π/4 =< φ =< π/4) ?

x = cos(φ)sqrt(2cos(2φ))
y = sin(φ)sqrt(2cos(2φ))

This is my attempt:

x = -pi/4:0.001:pi/4;
xy = cos(x).*sqrt(2*cos(2.*x));
yy = sin(x).*sqrt(2*cos(2.*x));
plot(x,xy,x,yy)
axis equal
grid on

Result

在此处输入图片说明

Following code segment may help you to find the solution. Next time, please clearly mention what you have tried and any error messages you saw.

x = -pi/4:pi/256:pi/4;

yx = cos(x).*sqrt(2*cos(2.*x));
yy = sin(x).*sqrt(2*cos(2.*x));

plot(x,yx,x,yy);
theta = linspace (-pi/4,pi/4);
x = cos(theta).*sqrt(2.*cos(2.*theta));
y = sin(theta).*sqrt(2.*cos(2.*theta));
plot(x,y,-x,-y), grid on, 
axis ('equal')

result

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM