how find the perimeter of irregular shape

2 views (last 30 days)
hello,have a good time. I have an equation known as the superfourmola equation,i have variables that change in the equation and my shape changes and i am looking for a way to get the perimeter of the shape.
This is the code I wrote :
clear all
close all
clc
warning off
tf=2*pi;
phi=0:0.01:tf;
m=4;
n1=9/16;
n2=6;
n3=2;
u=1;
v=1;
r=(((abs((1/u).*cos((m*phi)/4))).^n2)+((abs((1/v).*sin((m*phi)/4))).^n3)).^(-1/n1);
polar(phi,r)

Accepted Answer

Torsten
Torsten on 12 Jul 2022
Edited: Torsten on 12 Jul 2022
tf=2*pi;
phi=0:0.01:tf;
m=4;
n1=9/16;
n2=6;
n3=2;
u=1;
v=1;
r=(((abs((1/u).*cos((m*phi)/4))).^n2)+((abs((1/v).*sin((m*phi)/4))).^n3)).^(-1/n1);
[x,y] = pol2cart(phi,r);
% First method
perimeter = 0.0;
for i=1:numel(x)-1
perimeter = perimeter + sqrt((x(i+1)-x(i))^2 + (y(i+1)-y(i))^2);
end
perimeter
perimeter = 15.2441
% Second method
fn = cscvn([x;y]);
fnprime = fnder(fn);
Lfun = @(s) sqrt(sum(fnval(fnprime,s).^2,1));
L = integral(Lfun,fn.breaks(1),fn.breaks(end))
L = 15.2450

More Answers (0)

Community Treasure Hunt

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

Start Hunting!