Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Parametrization of curve
- x = @(t) sin(t) + cos(t).*(pi-t);
- y = @(t) -cos(t)+sin(t).*(pi-t);
- thetas = linspace(0, pi, 10000);
- curve.xi = x(thetas);
- curve.yi = y(thetas);
- circle.xi = sin(thetas);
- circle.yi = cos(thetas);
- %% Nice plot
- figure(1)
- clf
- grid
- hold on
- plot(curve.xi, curve.yi, 'b.')
- plot(circle.xi, circle.yi, 'y.')
- %% Calculate area below blue curve
- integral = 0;
- for i = 2:numel(curve.yi)
- delta = abs(curve.xi(i)-curve.xi(i-1));
- integral = integral + delta*curve.yi(i);
- end
- % Total should be:
- total = 2*(integral-pi/2) + pi^3/2;
- disp(['Total = ' num2str(total)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement