Plot the shape of a squid based on mathematical equations

조회 수: 4 (최근 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 .*

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by