I'm working on fitting a model to data I have collected. Within the model, I identify the optimal parameter values that best fit participant data then adjust and reduce the viewing window (range) to get more precise parameter values. I'm using linspace to generate new values to test against the participant data. Initially using a prior adaptation I had no issues. Once I edited my script to include a conditional "If" section to prevent parameters from being less than zero, I encountered the "Error using linspace (line 22) Inputs must be scalar. If I'm understanding the problem correctly its becuase I'm passing a vector into the linspace function instead of a scalar, but I don't understand why that is occuring now and was not the case with my previous adaptation. I'm assuming it has to do with the " if min_ < 0....." addition. Could someone help me to better understand where I'm making my error and how to correct this?
"Error using linspace (line 22) Inputs must be scalars."
"Error in Range_Adjustment (line 43) alphas = linspace(min_aro, max_aro,10);"
%Finds coordinates of optimal parameters for Condition 0
[x0,y0] = find(all_SSD_cond0 == min(min(all_SSD_cond0)));
%%% Identifies alpha and beta values that correspond to the coordinates for
%%% optimal parameters%%%
alphas(y0)
betas(x0)
%%%% Adjusts range for Condition 0 %%%
%Adjusts Alpha Range%
alpha_range = alpha_range.*0.7 % Decreases alpha range by 30%
min_aro = alphas(y0)-(alpha_range./(0.5)) %Creates optimized minimum of alpha range half distance away from identified optimal alpha value from previous iteration.
if min_aro < 0 % Conditional statement if minimum alpha range is less than zero min_aro = 0
min_aro = 0
end
max_aro = alphas(y0)+(alpha_range./(0.5)) %Creates optimized maximum value of alpha range half distance away from identified optimal alpha value from previous iteration.
%Adjusts Beta Range%
beta_range = beta_range.*0.7;% Decreases beta range by 30%
min_bro = betas(x0)-(beta_range./(0.5)); %Creates optimized minimum of beta range half distance away from identified optimal beta value from previous iteration.
if min_bro < 0 % Conditional statement if minimum beta range is less than zero min_bro = 0
min_bro = 0
end
max_bro = betas(x0)+(beta_range./(0.5)); %Creates optimized minimum of beta range half distance away from identified optimal beta value from previous iteration.
%%% Adjusts viewing frame and creates optimized alpha and beta parameters
%%% for fitting process%%%
alphas = linspace(min_aro, max_aro,10);
betas = linspace(min_bro, max_bro,10);
%alphas = linspace(alphas(y0)-(alpha_range./2), alphas(y0)+(alpha_range./2),10);
%betas = linspace(betas(x0)-(beta_range./2), betas(x0)+(beta_range./2),10);