Plotting a bird using mathematical equation issue.

3 ビュー (過去 30 日間)
Ahmed Mohamed Mansoor
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 日
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.

サインインしてコメントする。

カテゴリ

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by