Fit a sum of basis functions to an array

3 次查看(过去 30 天)
Can someone give me an idea how do I fit a sum of basis functions to an array? The context is image analysis and I am trying to find a convolution kernel from one image to the other. I am able to form the basis set, but unable to move forward from there on. P.S. I am very new to MATLAB.

回答(1 个)

Kim Winter
Kim Winter 2018-6-27
Hi, I have included an example below that might be pretty different than yours, but you can put your own values in. Below, I first create a function handle, with an array of my functions(in this case, sin(x) and cos(x)^2). I then create a series of inputs, x, using linspace. This creates 1000 equally spaced points between 1 and 1000. I then run my inputs through. Finally, I add my answers together.
%define basis functions using function handles
basis_funcs=@(x)sin(x);
basis_funcs2= @(x)(cos(x).^2);
%evenly spaced input array
inputs=linspace(1,1000,1000);
%input arrays into functions
output=basis_funcs(inputs);
output2=basis_funcs2(inputs);
%add outputs
outputfin=output+output2;
Hopefully this is what you're looking for!
  1 个评论
Anshuman Borgohain
Anshuman Borgohain 2018-6-28
Dear Kim,
Thank you for your reply. I understand that you are showing how to create the basis set and then add them. But my goal is to fit a sum of the basis functions to some data and get the coefficients of fit. Its like:
mydata = a*basis_funcs + b*basis_funcs2 + ..........
and I need a and b using some minimisation.
Best,
Anshuman

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by