how find the perimeter of irregular shape
2 views (last 30 days)
Show older comments
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)
0 Comments
Accepted Answer
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
% 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))
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots 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!