Matlab的离散点曲线导数曲率数值模拟方法

clc; clear all; close all;
x0 = linspace(0, 1);
y0 = sin(x0).*cos(x0);
h = abs(diff([x0(2), x0(1)]));
% 模拟一阶导
figure; box on; hold on;
ythe1 = cos(x0).^2 - sin(x0).^2; %理论一阶导
yapp1 = gradient(y0, h); %matlab数值近似
plot(x0, ythe1, '.');
plot(x0, yapp1, 'r');
legend('理论值', '模拟值');
title('模拟一阶导');
% 模拟二阶导
figure; box on; hold on;
ythe2 = (-4)*cos(x0).*sin(x0); %理论二阶导
yapp2 = 2*2*del2(y0, h); %matlab数值近似
plot(x0, ythe2,'.');
plot(x0, yapp2,'r');
legend('理论值', '模拟值');
title('模拟二阶导');
% 模拟曲率
syms x y
y = sin(x)*cos(x);
yd2 = diff(y, 2);
yd1 = diff(y, 1);
k = abs(yd2)/(1+yd1^2)^(3/2);
k1 = subs(k, x, x0);
k2 = abs(yapp2)./(1+yapp1.^2).^(3/2);
figure; box on; hold on;
plot(x0, k1, '.');
plot(x0, k2, 'r');
legend('理论值', '模拟值', 'Location', 'NorthWest');
title('模拟曲率');

效果:

未命名.bmp (595.01 KB)

2010-3-7 17:01


未命名1.bmp (574.92 KB)

2010-3-7 17:01


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值