⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regression3.m

📁 空间三维螺旋曲线的回归分析; 空间sinc曲线的回归分析。
💻 M
字号:
%SVC的三维回归!!!
clc
clear all
global p1;
p1=102.111;
e=0.005;
C=9000;
t=linspace(8*pi,20*pi,501);
%画出三维的曲线
figure(1);
subplot(221);plot3(1.5*t.*sin(t),1.5*t.*cos(t),t,'-r');title('空间三维曲线');
Box on;grid on;
%从8*pi->16*pi取一些点用于训练SVM
z=8*pi:2:16*pi;
lenZ=length(z);
x=1.5*z.*sin(z);
y=1.5*z.*cos(z);

subplot(222);plot3(x,y,z,'or');
Box on;grid on;hold on;
X=[x;y];
X=X';
Y=z;
Y=Y';
lenY=length(Y);
[nsv, beta, bias] = svr(X,Y,'rbf',C,'eInsensitive',e);
%用于测试的数据
zz=8*pi:0.1:20*pi;
xx=1.5*zz.*sin(zz);
yy=1.5*zz.*cos(zz);
testX=[xx;yy];
testX=testX';
%testX=[ x2 x1];
tstY = svroutput(X,testX,'rbf',beta, bias)
len=length(tstY);
%画出分类结果
%for i=1:len;
subplot(222);  plot3(xx,yy,tstY,'-b',1.5*t.*sin(t),1.5*t.*cos(t),t,'-r');title('12点SVM三维曲线回归');
    %end
Box on;grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%从8*pi->16*pi取一些点用于训练SVM
z=8*pi:1:16*pi;
lenZ=length(z);
x=1.5*z.*sin(z);
y=1.5*z.*cos(z);
subplot(223);plot3(x,y,z,'or');
Box on;grid on;hold on;
X=[x;y];
X=X';
Y=z;
Y=Y';
lenY=length(Y);
[nsv, beta, bias] = svr(X,Y,'rbf',C,'eInsensitive',e);
%用于测试的数据
zz=8*pi:0.1:20*pi;
xx=1.5*zz.*sin(zz);
yy=1.5*zz.*cos(zz);
testX=[xx;yy];
testX=testX';
%testX=[ x2 x1];
tstY = svroutput(X,testX,'rbf',beta, bias)
len=length(tstY);
%画出分类结果
%for i=1:len;
subplot(223);  plot3(xx,yy,tstY,'-b',1.5*t.*sin(t),1.5*t.*cos(t),t,'-r');
title('24点SVM三维曲线回归');
    %end
Box on;grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%从8*pi->16*pi取一些点用于训练SVM
z=8*pi:0.5:16*pi;
lenZ=length(z);
x=1.5*z.*sin(z);
y=1.5*z.*cos(z);
subplot(224);plot3(x,y,z,'or');
Box on;grid on;hold on;
X=[x;y];
X=X';
Y=z;
Y=Y';
lenY=length(Y);
[nsv, beta, bias] = svr(X,Y,'rbf',C,'eInsensitive',e);
%用于测试的数据
zz=8*pi:0.1:20*pi;
xx=1.5*zz.*sin(zz);
yy=1.5*zz.*cos(zz);
testX=[xx;yy];
testX=testX';
%testX=[ x2 x1];
tstY = svroutput(X,testX,'rbf',beta, bias)
len=length(tstY);
%画出分类结果
%for i=1:len;
subplot(224);  plot3(xx,yy,tstY,'-b',1.5*t.*sin(t),1.5*t.*cos(t),t,'-r');title('48点SVM三维曲线回归');
    %end
Box on;grid on;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%BP神经网络
% clc
% %通过下面两个参数值的改变比较结果
% n=6; %设置网络隐单元的神经元数目
% 
% %建立相应的BP网络 
% bpX=X';
% net = newff(minmax(bpX),[16,1],{'tansig','purelin'},'traingdm');
% %绘出仿真得到的曲线
% %训练网络
% net.trainParam.epochs = 1000;
% net.trainParam.goal = 0.001;
% bpY=Y';
% net = train(net,bpX,bpY);
% %对训练后的网络进行仿真
% bptestX=testX';
% t1 = sim(net,bptestX);
% %绘出训练后的仿真结果
% figure(2);
% subplot(223);  plot3(xx,yy,t1,'-b',1.5*t.*sin(t),1.5*t.*cos(t),t,'-r');
% Box on;grid on;
% % hold on

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -