Plot the shape of a squid based on mathematical equations

3 ビュー (過去 30 日間)
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022 年 10 月 10 日
コメント済み: Dyuman Joshi 2022 年 10 月 10 日
The following equations plot a shape of a squid (as seen in the image below). I attempted to code the equations but I think there is something wrong in my code (see code below).
My code is:
clear; close all; clc;
[x,y] = meshgrid(linspace(-1,1,1000),linspace(-1,1,1000));
tot =0;
for i = 1:10
tot = tot + ((100/91) * (0.41 - (1/pi)*atan(25*x - 45)) .* ...
( 0.5 + (1/pi)*atan(25*(x + 0.3 + 0.45*((10*i-55)./45).^20))).* ...
exp(((x.^3./50 + x./4 + ((i-5)./60.*atan(8*x-384/29)) .* ...
(((-1).^(i+1)./20).*cos(5*x)-(i/60)) .*...
(0.475 - x./2 + (x-0.95).^2) .* (pi/2 - atan(40*x-38))-y).^2).*...
(-1500*pi + 3000.*atan(6 - 40.*(x-1.45).^2)) ));
end
f = -0.2 + tot.*(1 - 150*exp(-20*(500*(x-1).^2 + 500*(y-0.25).^2-1).^2));
f(f>0) = 1;
f(f<0) = 0;
contourf(x,y,f,[0 1])
axis equal
map = [1 1 1 ; 0 0 0];
colormap(map)
As you can see this is the plot I got.
Can you please check and let me know where I went wrong?

採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 10 月 10 日
There are some mistakes while defining tot.
3rd line inside atan it should be 384/25
and the immediate next symbol should be + (addition) instead of .*
  2 件のコメント
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2022 年 10 月 10 日
Thank you sir. It worked perfectly.
Dyuman Joshi
Dyuman Joshi 2022 年 10 月 10 日
You are welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by