Plotting a bird using mathematical equation issue.

조회 수: 9 (최근 30일)
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022년 10월 5일
댓글: Ahmed Mohamed Mansoor 2022년 10월 5일
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:
  1. 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?
  2. 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:

채택된 답변

KSSV
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
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022년 10월 5일
Matter of fact. Yes. You were correct. Sorry about not considering your comment. and thank you for pointing that out.
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022년 10월 5일
For example I tried to use comet but it did not seem to work.
Can I also ask another question. The beak of the bird at the very top seemes to be different from the actual piture. Any idea why this happens?

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

추가 답변 (1개)

Benjamin Thompson
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.
  댓글 수: 1
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022년 10월 5일
oh. I am still a little new to this. But from what I know the use of scatter is okay. The scatter function maps the elements in Rk to colors in the current colormap as far as I know.
But any help would do.

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

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by