日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

径向基函数插值(2)一维数据的插值

發布時間:2025/4/16 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 径向基函数插值(2)一维数据的插值 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

假設我們有N組數據(xi,yi),,,,,,,,這時我們根據徑向基函數我們的目的主要是找到徑向基函數中的位置參數的值,

我們要用這些已知數據的值用最小二乘法得到這些參數。。

現在我們用一般的方法matlb自帶的插值函數進行新值得計算:

<span style="font-size:18px;">x = 0:1.25:10; y = sin(x); xi = 0:.1:10; %Matlab yi = interp1(x,y,xi); subplot(2,1,1); plot(x,y,'o',xi,yi, xi, sin(xi),'r'); title('Interpolation using Matlab function interp1');</span>


現在我們用徑向基函數的方法進行插值

1、

<span style="font-size:18px;">x = 0:1.25:10; y = sin(x); xi = 0:.1:10; </span>產生數據集,和需要插值的數據

2、設定調用函數的參數

% 1D Interpolation %**************************************************************************x = 0:1.25:10; y = sin(x); xi = 0:.1:10; %Matlab yi = interp1(x,y,xi); subplot(2,1,1); plot(x,y,'o',xi,yi, xi, sin(xi),'r'); title('Interpolation using Matlab function interp1'); %% %RBF %op=rbfcreate(x, y,'RBFFunction', 'thinplate'); rbfcheck(op); %op=rbfcreate(x, y,'RBFFunction', 'linear'); rbfcheck(op); %op=rbfcreate(x, y,'RBFFunction', 'cubic'); rbfcheck(op); %op=rbfcreate(x, y,'RBFFunction', 'gaussian'); rbfcheck(op); op=rbfcreate(x, y,'RBFFunction', 'multiquadric', 'RBFConstant', 2); rbfcheck(op); op=rbfcreate(x, y); rbfcheck(op); %op=rbfcreate(x, y,'RBFFunction', 'gaussian'); %op=rbfcreate(x, y); fi = rbfinterp(xi, op); subplot(2,1,2); plot(x, y,'o', xi, fi,xi, sin(xi),'r'); title('RBF interpolation'); 求解徑向基函數的系數過程 function options = rbfcreate(x, y, varargin) %RBFCREATE Creates an RBF interpolation % OPTIONS = RBFSET(X, Y, 'NAME1',VALUE1,'NAME2',VALUE2,...) creates an % radial base function interpolation % % RBFCREATE with no input arguments displays all property names and their % possible values. % %RBFCREATE PROPERTIES % % % Alex Chirokov, alex.chirokov@gmail.com % 16 Feb 2006 tic; % Print out possible values of properties. if (nargin == 0) & (nargout == 0)fprintf(' x: [ dim by n matrix of coordinates for the nodes ]\n');fprintf(' y: [ 1 by n vector of values at nodes ]\n');fprintf(' RBFFunction: [ gaussian | thinplate | cubic | multiquadrics | {linear} ]\n');fprintf(' RBFConstant: [ positive scalar ]\n');fprintf(' RBFSmooth: [ positive scalar {0} ]\n');fprintf(' Stats: [ on | {off} ]\n');fprintf('\n');return; end Names = ['RBFFunction ''RBFConstant ''RBFSmooth ''Stats ' ]; [m,n] = size(Names); names = lower(Names);options = []; for j = 1:moptions.(deblank(Names(j,:))) = []; end%************************************************************************** %Check input arrays %************************************************************************** [nXDim nXCount]=size(x); [nYDim nYCount]=size(y);if (nXCount~=nYCount)error(sprintf('x and y should have the same number of rows')); end;if (nYDim~=1)error(sprintf('y should be n by 1 vector')); end;options.('x') = x; options.('y') = y; %************************************************************************** %Default values %************************************************************************** options.('RBFFunction') = 'linear'; options.('RBFConstant') = (prod(max(x')-min(x'))/nXCount)^(1/nXDim); %approx. average distance between the nodes options.('RBFSmooth') = 0; options.('Stats') = 'off';%************************************************************************** % Argument parsing code: similar to ODESET.m %**************************************************************************i = 1; % A finite state machine to parse name-value pairs. if rem(nargin-2,2) ~= 0error('Arguments must occur in name-value pairs.'); end expectval = 0; % start expecting a name, not a value while i <= nargin-2arg = varargin{i};if ~expectvalif ~isstr(arg)error(sprintf('Expected argument %d to be a string property name.', i));endlowArg = lower(arg);j = strmatch(lowArg,names);if isempty(j) % if no matcheserror(sprintf('Unrecognized property name ''%s''.', arg));elseif length(j) > 1 % if more than one match% Check for any exact matches (in case any names are subsets of others)k = strmatch(lowArg,names,'exact');if length(k) == 1j = k;elsemsg = sprintf('Ambiguous property name ''%s'' ', arg);msg = [msg '(' deblank(Names(j(1),:))];for k = j(2:length(j))'msg = [msg ', ' deblank(Names(k,:))];endmsg = sprintf('%s).', msg);error(msg);endendexpectval = 1; % we expect a value nextelseoptions.(deblank(Names(j,:))) = arg;expectval = 0; endi = i + 1; endif expectvalerror(sprintf('Expected value for property ''%s''.', arg)); end%************************************************************************** % Creating RBF Interpolatin %**************************************************************************%選擇所用基函數的形式 這五種函數 高斯 線性 立方 薄板 多項式 switch lower(options.('RBFFunction')) case 'linear' options.('rbfphi') = @rbfphi_linear; %線性case 'cubic'options.('rbfphi') = @rbfphi_cubic;%立方case 'multiquadric'options.('rbfphi') = @rbfphi_multiquadrics;%多項式case 'thinplate'options.('rbfphi') = @rbfphi_thinplate;%薄板case 'gaussian'options.('rbfphi') = @rbfphi_gaussian;%高斯型otherwiseoptions.('rbfphi') = @rbfphi_linear; endphi = options.('rbfphi'); % 調用函數,求解出數據集使用調用||x-xi||函數的值 A=rbfAssemble(x, phi, options.('RBFConstant'), options.('RBFSmooth')); b=[y'; zeros(nXDim+1, 1)]; %這是數據集對應的輸出值Y %inverse rbfcoeff=A\b; %這是徑向基函數對應的參數系數%SVD % [U,S,V] = svd(A); % % for i=1:1:nXCount+1 % if (S(i,i)>0) S(i,i)=1/S(i,i); end; % end; % rbfcoeff = V*S'*U*b;options.('rbfcoeff') = rbfcoeff;if (strcmp(options.('Stats'),'on'))fprintf('%d point RBF interpolation was created in %e sec\n', length(y), toc); fprintf('\n'); end;function [A]=rbfAssemble(x, phi, const, smooth) %x 為已知的數據集 %phi 表示調用的是哪個基函數形式 %const 表示高斯形式時的方差 %smooth 偏移量 一般為0 [dim n]=size(x); %得到數據集的維數 A=zeros(n,n); %初始化有數據集帶入基函數中得到的值 for i=1:nfor j=1:ir=norm(x(:,i)-x(:,j)); %每個數據跟其他數據之間的距離temp=feval(phi,r, const); %帶入相應的基函數中得到的值,存儲到A中,用于求解系數A(i,j)=temp;A(j,i)=temp;endA(i,i) = A(i,i) - smooth; end % Polynomial part P=[ones(n,1) x']; A = [ A PP' zeros(dim+1,dim+1)]; %************************************************************************** % Radial Base Functions %************************************************************************** %五種基函數的表達式 function u=rbfphi_linear(r, const) u=r;function u=rbfphi_cubic(r, const) u=r.*r.*r;function u=rbfphi_gaussian(r, const) u=exp(-0.5*r.*r/(const*const));function u=rbfphi_multiquadrics(r, const) u=sqrt(1+r.*r/(const*const));function u=rbfphi_thinplate(r, const) u=r.*r.*log(r+1);這是進行求解新插入值得過程

已知新的插入值,和上一個函數得到的徑向基函數的參數,進行計算,得到新插入值的解

function [f] = rbfinterp(x, options) %x 為插值的數據 %options 徑向基函數的參數設定 tic; phi = options.('rbfphi'); %調用的基函數形式 rbfconst = options.('RBFConstant');%基函數的方差設置 nodes = options.('x'); %已知的數據集x rbfcoeff = (options.('rbfcoeff'))';%求得的徑向基函數的系數[dim n] = size(nodes); [dimPoints nPoints] = size(x);if (dim~=dimPoints)error(sprintf('x should have the same number of rows as an array used to create RBF interpolation')); end;f = zeros(1, nPoints); r = zeros(1, n);for i=1:1:nPointss=0;r = (x(:,i)*ones(1,n)) - nodes; %新數據點到已知每個數據點的距離r = sqrt(sum(r.*r, 1)); % for j=1:n % r(j) = norm(x(:,i) - nodes(:,j)); % ends = rbfcoeff(n+1) + sum(rbfcoeff(1:n).*feval(phi, r, rbfconst));for k=1:dims=s+rbfcoeff(k+n+1)*x(k,i); % linear partendf(i) = s; end;if (strcmp(options.('Stats'),'on'))fprintf('Interpolation at %d points was computed in %e sec\n', length(f), toc); end;



總結

以上是生活随笔為你收集整理的径向基函数插值(2)一维数据的插值的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 天天草天天爽 | 麻豆网站在线看 | 男女无遮挡做爰猛烈视频 | 国产精品久久久久久久久 | 天堂www中文在线资源 | 国产噜噜噜噜久久久久久久久 | 亚洲精品欧洲精品 | 免费又黄又爽又猛大片午夜 | 丰满熟女人妻一区二区三 | sm国产在线调教视频 | 亚洲综合在线视频 | 黄色网址国产 | 久久97久久97精品免视看 | 国产肥老妇视频 | 鲁鲁在线 | 国产精品久久久久久亚洲调教 | 欧美亚洲一级片 | 99国产精品国产免费观看 | 国产精品2018 | 亚洲少妇激情 | 天天做天天爱天天操 | 中文字幕一区二区三区精品 | av综合站| 中文字幕33页 | 亚洲日本香蕉视频 | 午夜小视频在线观看 | 丁香六月综合 | 亚洲xxxx天美 | 成人av在线网 | 国产毛片一区 | 色偷偷伊人 | 国产成人精品免费网站 | 无码人妻丰满熟妇啪啪 | 国产精品一区三区 | 亚洲 欧美 另类 综合 偷拍 | 少妇一级淫片免费播放 | 91丝袜呻吟高潮美腿白嫩在线观看 | 四川操bbb| 在线射 | 久久久久久久久久久久久女过产乱 | 成年人免费视频播放 | 日韩中文字幕网站 | 国产成人精品亚洲 | 91麻豆精品一区二区三区 | 都市激情亚洲色图 | 91成人短视频在线观看 | 中文字幕高清在线播放 | xxxx96| 男女啪啪无遮挡 | 欧美成年人视频 | 美女扒开下面让男人捅 | sm调教羞耻姿势图片 | 91精品国产成人 | 怡红院精品视频 | 红色假期黑色婚礼2 | 30一40一50老女人毛片 | 成人做受视频试看60秒 | 97成人精品视频在线观看 | 台湾av在线| 日韩aa | 婷婷久久丁香 | 亚洲高潮av | 日本三级吃奶头添泬无码苍井空 | 少妇人妻偷人精品视频蜜桃 | 亚洲精品污 | 卡一卡二卡三 | 神马久久av | 理论片毛片 | 国产精品99久久久久久久久久久久 | 青青草国产精品 | 欧美性受xxxx黒人xyx性爽 | 女同性69囗交| 美女黄视频大全 | 欧美亚洲日本国产 | 91成人黄色| 日韩不卡免费视频 | 邻居少妇张开腿让我爽了在线观看 | 性做久久久久久免费观看欧美 | eeuss鲁片一区二区三区在线观看 | 精品视频在线免费 | 秋霞欧美一区二区三区视频免费 | 国产亚洲精品久久777777 | av影院在线播放 | 98自拍视频 | 久久91av | 超能一家人电影免费喜剧在线观看 | 婷婷伊人| 日韩精品一区二区三区视频 | 免费av影视 | 国产极品一区 | 丝袜美女av| 国产蜜臀av一区二区 | 国产精品白嫩极品美女视频 | 国产精品网站视频 | www在线播放 | 日p视频在线观看 | 妖精视频在线观看免费 | 99riav国产精品| 波多野结衣亚洲一区二区 |