Hi Charu,
The RBF kernel function itself is defined solely by the distance between the feature vectors and the parameter that controls the kernel's spread (γ or σ).
function G = myrbf(U,V)
gamma = 0.016;
sig = 1/sqrt(2*gamma);
G = exp(-((norm(U-V))^2)/(2*(sig^2)));
end
The kernel parameter C, often referred to as the cost or penalty parameter, does not belong in the kernel function. Instead, C is used during the SVM training phase to control the trade-off between maximizing the margin and minimizing classification errors. In the optimization problem for SVM, C appears as a constraint on the Lagrange multipliers (e.g., 0 ≤ αᵢ ≤ C).
When implementing the SVM you can use the custom RBF function as is and incorporate C in the constraints of the quadratic programming formulation which can be solved using 'quadprog' in MATLAB. This separation ensures that your kernel accurately computes the similarity measure, while 'C' manages the overall model complexity and regularization during training.
You can refer to the 'quadprog' documentation: https://www.mathworks.com/help/optim/ug/quadprog.html to know more about solving the soft-constraint SVM through quadratic programming optimization.
Hope this helps!