Clear Filters
Clear Filters

Fit a sum of basis functions to an array

3 views (last 30 days)
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.

Answers (1)

Kim Winter
Kim Winter on 27 Jun 2018
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 Comment
Anshuman Borgohain
Anshuman Borgohain on 28 Jun 2018
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

Sign in to comment.

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!