Plotting a bird using mathematical equation issue.
조회 수: 9 (최근 30일)
이전 댓글 표시
Hello, I saw these set of equations that plot a bird using circles (See Image Below). I was able to code it down and the plot does not seem to be correct. However, there are a few issues with my code and it would be great if anybody could help.
My questions are:
- The plot does not seem to be right when I run it (see image below). Can you please check if the code is correct to get the same plot as in the image above?
- If I wanted to animate the plot, how would I do it?
clear; close all; clc;
A =@(k) sin((pi*k)./20000);
B =@(k) cos((31*pi*k)./10000);
C =@(k) sin((6*pi*k)./10000);
D =@(k) cos((31*pi*k)./10000);
E =@(k) sin((pi/2)*((k-10000)./(10000)).^7-(pi/5));
F =@(k) cos((pi/2)*((k-10000)./(10000)).^7-(pi/5));
G =@(k) sin((3*pi*k)./20000);
H =@(k) cos((3*pi)*((k-10000)./(100000)));
I =@(k) cos((9*pi)*((k-10000)./(100000)));
J =@(k) cos((36*pi)*((k-10000)./(100000)));
K =@(k) cos(((31*pi*k)./(10000))+((25*pi)/32));
L =@(k) cos((62*pi*k)./10000);
x = 1:9830;
% these are the Xk values
Xk = A(x).^12 .* (0.5*B(x).^16.*C(x) + (1/6)*D(x).^20) + ((3*x)./20000) ...
+ B(x).^6 .*E(x);
% these are the Yk vlues
Yk = (-9/4)*B(x).^6.*F(x).*((2/3)+(A(x).*G(x)).^6) + ...
(3/4)*H(x).^10.*I(x).^10.*J(x).^14 +...
(7/10)*((x-10000)./(100000)).^2;
% This are the Rk values
Rk = A(x).^10.*((1/4)*K(x).^20 + (1/20)*B(x).^2) + (1/30).*((3/2)-L(x).^2);
figure()
scatter(Xk,Yk,[],Rk)
colormap(jet)
The plot looks like this:
댓글 수: 0
채택된 답변
KSSV
2022년 10월 5일
You need to modify the radius Rk so that, it gives the look.
clear; close all; clc;
A =@(k) sin((pi*k)./20000);
B =@(k) cos((31*pi*k)./10000);
C =@(k) sin((6*pi*k)./10000);
D =@(k) cos((31*pi*k)./10000);
E =@(k) sin((pi/2)*((k-10000)./(10000)).^7-(pi/5));
F =@(k) cos((pi/2)*((k-10000)./(10000)).^7-(pi/5));
G =@(k) sin((3*pi*k)./20000);
H =@(k) cos((3*pi)*((k-10000)./(100000)));
I =@(k) cos((9*pi)*((k-10000)./(100000)));
J =@(k) cos((36*pi)*((k-10000)./(100000)));
K =@(k) cos(((31*pi*k)./(10000))+((25*pi)/32));
L =@(k) cos((62*pi*k)./10000);
x = 1:9830;
% these are the Xk values
Xk = A(x).^12 .* (0.5*B(x).^16.*C(x) + (1/6)*D(x).^20) + ((3*x)./20000) ...
+ B(x).^6 .*E(x);
% these are the Yk vlues
Yk = (-9/4)*B(x).^6.*F(x).*((2/3)+(A(x).*G(x)).^6) + ...
(3/4)*H(x).^10.*I(x).^10.*J(x).^14 +...
(7/10)*((x-10000)./(100000)).^2;
% This are the Rk values
Rk = A(x).^10.*((1/4)*K(x).^20 + (1/20)*B(x).^2) + (1/30).*((3/2)-L(x).^2);
figure()
scatter(Xk,Yk,Rk*8000,Rk)
colormap(jet)
axis equal
댓글 수: 5
추가 답변 (1개)
Benjamin Thompson
2022년 10월 5일
The radius values Rk do not seem to be used properly. Are you calling scatter correctly? Looks like maybe you need three arguments instead of 4.
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!