Youu have several typos in the problem. I corrected them as best I could, but please make sure that I didn't change anything that you meant to write.
Your main problem is not passing the extra data for the problem. Here is my version, with typos corrected as best I could and with data passed correctly:
function [f] = ErrorFunction(x,raw_signal_ref,raw_signal_sam,raw_time_ref)
fp_signal = fp_signal +...
sim_signal_sam = cor_fac*(4*x(1))/(x(1)+1)^2*x(2)*...
((raw_signal_ref*k.*((raw_time_ref*(1e-12)-(x(1)-1)*(x(4)*(1e-3)/c))/x(3))) + fp_signal);
f = sum(sim_signal_sam - raw_signal_sam);
Here is how I called that function after placing x0 in the workspace:
fun = @(x)ErrorFunction(x,raw_signal_ref,raw_signal_sam,raw_time_ref);
x_optimized = fminsearch(fun,x0);
When I run the problem fminsearch exits with this message:
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -907777101105805751482258996129483335894703616332083863052416498711493108878399830640514887677380554503199361365622832602682026028412939674686787717791027291595548412048643393197842340492625295522296145364560679359874843053719749781643093886750418805308954509312.000000
So I am not sure that my corrections were complete or correct, but at least it now runs.
MATLAB mathematical toolbox documentation