I am getting the error "inner matrix dimensions must agree" in the code below
t = linspace(0,10,100);
x_exact = exp(-(t-4).^2); % exact solution
x_exact = x_exact';
lambda = randn(size(x_exact)); % diagonal values
A = diag(lambda); % diagonal matrix
y = A*x_exact; % exact data
delta = 1e-3*randn(size(y)); % noise
y_delta = y+delta; % noisy data
%% Define functional
% preallocate the memory
N_alpha = 3;
alpha = zeros(1,N_alpha);
resulting_x = cell(1,N_alpha);
alpha(1) = 1e-9;
alpha(N_alpha) = 1;
x = zeros(100,1);
for n = 1:N_alpha
alpha(n) = alpha(1)+(n-1)*((alpha(N_alpha)-alpha(1))/(N_alpha-1));
alphas = alpha(n);
T = @(x) 1/2*norm(A*x-y_delta)^2+(alphas/2)*norm(x)^2;
resulting_x{n} = fminsearch(@(x) T(x),zeros(1,N_alpha));
end
specifically on the line T = @(x) 1/2*norm(A*x-y_delta)^2+(alphas/2)*norm(x)^2;. I have tried to change * to the pointwise product .* but then I get the error "inner matrix dimensions must agree".
x is supposed to be vector input which will be well defined when multiplied by the matrix A, but this function handle is causing some problems