📄 first.m
字号:
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in listbox1.
function listbox8_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox8_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global dat;
global datt;
global result resultstype;
result=plafit(dat,datt);
resultstype='*平面拟合*';
set(handles.listbox2,'string',result)
guidata(hObject,handles);
save result
%;
% --------------------------------------------------------------------
function Untitled_12_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global dat;
global datt;
global result resultstype;
result=curfit2(dat,datt);
resultstype='*二次曲线拟合*';
set(handles.listbox2,'string',result)
guidata(hObject,handles);
save result
%;
% --------------------------------------------------------------------
function Untitled_13_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global dat;
global datt;
global result resultstype;
result=curfit3(dat,datt);
resultstype='*三次曲线拟合*';
set(handles.listbox2,'string',result)
guidata(hObject,handles);
save result
%;
% --------------------------------------------------------------------
function Untitled_14_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global dat;
global datt;
global result resultstype ;
t1=dat;
t2=datt;
p=t1(:,1);
p=p';
pp=t2(:,1);
pp=pp';
h=(t1(:,2)-t1(:,3))';
[pn,minp,maxp,hn,minh,maxh]=premnmx(p,h);%归一化处理
%P,T分别为原始输入和输出数据,minp和maxp分别为P中的最小值和最大值。mint和maxt分别为T的最小值和最大值。
%premnmx函数用于将网络的输入数据或输出数据进行归一化,归一化后的数据将分布在[-1,1]区间内。
% b=son(pn',1);
% b1=b'*b;
% b2=b'*hn';
% a=inv(b1)*b2;
%用plot做二维图象!---------------------------------------------------
a=polyfit(pn,hn,1);
pp1=tramnmx(pp,minp,maxp);%归一化处理
figure(2)
hold on
xx1=[-1.0:0.05:1.0];
yy1=a(2)+a(1)*xx1;
xx=postmnmx(xx1,minp,maxp);
yy=postmnmx(yy1,minh,maxh);
subplot(2,2,1);
plot(p,h,'*'),title('*一次曲线拟合*');
hold on
subplot(2,2,1);
plot(xx,yy,'-r');
%用plot做二维图象!---------------------------------------------------
a=polyfit(pn,hn,2);
pp1=tramnmx(pp,minp,maxp);%归一化处理
xx1=[-1.0:0.05:1.0];
yy1=a(3)+a(2)*xx1+a(1)*xx1.^2;
xx=postmnmx(xx1,minp,maxp);
yy=postmnmx(yy1,minh,maxh);
subplot(2,2,2);
plot(p,h,'*'),title('*二次曲线拟合*');
hold on
subplot(2,2,2);
plot(xx,yy,'-y')
%用plot做二维图象!---------------------------------------------------
a=polyfit(pn,hn,3);
pp1=tramnmx(pp,minp,maxp);%归一化处理
xx1=[-1.0:0.05:1.0];
yy1=a(4)+a(3)*xx1+a(2)*xx1.^2+a(1)*xx1.^3;
xx=postmnmx(xx1,minp,maxp);
yy=postmnmx(yy1,minh,maxh);
subplot(2,2,3);
plot(p,h,'*'),,title('*三次曲线拟合*');
hold on
subplot(2,2,3);
plot(xx,yy,'-b')
% --- Executes during object creation, after setting all properties.
function uipanel2_CreateFcn(hObject, eventdata, handles)
% hObject handle to uipanel2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --------------------------------------------------------------------
function Untitled_15_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global result resultstype;
[FileName PathName]=uigetfile(('*.txt'),'Choose a File');
L=length(FileName);
if L<5
msgbox(' 文件未选,请重新选择','提示');
return;
end
L='';
str=[PathName FileName];
fid1=fopen(str,'at');
fprintf(fid1,resultstype);
fprintf(fid1,'%7.3f',result);
fprintf(fid1,'\n');
fclose(fid1);
msgbox(' 保存完毕','提示');
result=''
resultstype='';
global datt;
global wordd;
n=size(datt);
if n(2)==3
str_dat=[blanks(13) 'x' blanks(20) 'h1' blanks(19) 'h2'];
elseif n(2)==4
str_dat=[blanks(13) 'x' blanks(24) 'y' blanks(22) 'h1' blanks(15) 'h2'];
elseif n(2)==2
str_dat=[blanks(13) 'x' blanks(24) 'y'];
elseif n(2)==1
str_dat=[blanks(13) 'x'];
end
for i = 1 : n(1)
str_dat1=sprintf('%13.3f',datt(i,1));
for j =2:n(2)
str_dat1=[str_dat1 blanks(3) sprintf('%13.3f',datt(i,j))];
end
str_dat=char(str_dat,str_dat1);
end
set(handles.listbox2,'string',str_dat);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%实测数据导入
[FileName PathName]=uigetfile(('*.xls'),'打开实测数据文件');
L=length(FileName);
if L<5
msgbox(' 文件未选,请重新选择','提示');
return;
end
L='';
str=[PathName FileName];
scdata=xlsread(str);
%拟合数据导入
[FileName PathName]=uigetfile(('*.txt'),'打开实测数据文件');
L=length(FileName);
if L<5
msgbox(' 文件未选,请重新选择','提示');
return;
end
L='';
str=[PathName FileName];
nihe_data=textread(str,'%s');
fid1=fopen(str,'at');
n=length(nihe_data);
j=0;
for i=1:n
a=str2mat(nihe_data(i));
if a(1)=='*'
j=j+1;
nhdata(j).name=a;
k=0;
else
k=k+1;
nhdata(j).d(k)=str2num(a);
end
end
fprintf(fid1,'\n');
for i = 1:j
m=scdata-(nhdata(i).d)';
nhdata(i).inerror=sqrt(sum(m.*m)/k);
fprintf(fid1,'%s',nhdata(i).name);
fprintf(fid1,'%s',[blanks(2) '其中误差为:']);
fprintf(fid1,'%6.4f',nhdata(i).inerror);
fprintf(fid1,'\n');
end
fclose(fid1)
msgbox('精度评定完毕,并成功保存','提示');
% --- Executes during object creation, after setting all properties.
function pushbutton5_CreateFcn(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object deletion, before destroying properties.
function pushbutton5_DeleteFcn(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -