%产生拟合曲线,并求某点导数
% hObject handle to btn_ployder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=0.01:0.01:14;
steps=str2num(get(handles.edit_steps,'string')) ;
if length(steps)==1%必须是单个曲线
switch get(handles.popupmenu_pick,'value')
case 1
y=BESSELJ(steps(1),x);
case 2
y=BESSELY(steps(1),x);
end
a=polyfit(x,y,str2num(get(handles.edit_polyStep,'string')));%获取拟合多项式系数
a1=polyder(a);%多项式一阶导数
a2=polyder(a1);%多项式二阶导数
t=polyval(a,x);
hold on;
plot(x,y,'b');%绘制贝塞尔曲线
plot(x,t,'r:');%绘制拟合曲线
hold off;
xValue=str2num(get(handles.edit_xValue,'string')) ;
yValue=polyval(a,xValue);%函数值
dy1Value=polyval(a1,xValue);%一阶导数值
dy2Value=polyval(a2,xValue);%二阶导数值
set(handles.edit_yValue,'string',num2str(yValue));%显示
set(handles.edit_dy1Value,'string',num2str(dy1Value));
set(handles.edit_dy2Value,'string',num2str(dy2Value));
end