MATLAB Answers

Can anyone help me to apply RBF kernel function in matlab and how to write its equation?

5 views (last 30 days)
MINO GEORGE on 10 May 2021
Commented: MINO GEORGE on 12 May 2021
The equation is K(X,X') = exp(-||X-X'||2/2sigma2). Any help is appreciated

Accepted Answer

the cyclist
the cyclist on 10 May 2021
Edited: the cyclist on 10 May 2021
% Define sigma
sigma = 0.4;
% Define the function
K = @(x1,x2) exp(-sum((x1-x2).^2)./(2.*sigma.^2));
% Apply the function to two vectors
K([1; 2; 3],[1; 2; 4])
ans = 0.0439
(I think I got the norm part coded right, but you should double-check that because I didn't.)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!