Unable to perform assignment because the indices on the left side are not compatible with the size of the right side
1 次查看(过去 30 天)
显示 更早的评论
When I run this code I get the above warning. Can someone see what I am doing wrong?
%% Optimizer (SPSA method)
n = 100;
theta = hourly_rating;
thetamin = hourly_rating ./ hourly_rating;
thetamax = hourly_rating .* 1.1;
alpha = 0.602 ;
gamma = 0.101 ;
a = 0.75;
c = 0.1;
A = 100;
p = numel(theta);
for k=0:n-1
ak=a/(k+1+A)^alpha;
ck=c/(k+1)^gamma;
delta=2*round(rand(p,1))-1; %Fixme: How to determine delta
for j=1:size(ws,2)
current_year = strcat('y_',num2str((start_year +j)));
for i=1:size(year.(current_year),1)
thetaplus(i,j) = theta(i,j) + ck*delta;
thetaminus(i,j) = theta(i,j) - ck*delta;
end
end
yplus=objective_func(thetaplus,ws,app,input,start_year,year,eprice);
yminus=objective_func(thetaminus,ws,app,input,start_year,year,eprice);
ghat=(yplus-yminus)./(2*ck*delta);
for j=1:size(ws,2)
current_year = strcat('y_',num2str((start_year +j)));
for i=1:size(year.(current_year),1)
theta(i,j) = theta(i,j) - ak*ghat;
end
end
% theta=min(theta,thetamax); %Fixme: where to implement this?
% theta=max(theta,thetamin); %Fixme: idem?
end
1 个评论
Srivardhan Gadila
2020-4-5
@Sietse van den Elzen, can you provide details on which line you are getting the error, values of variables like hourly_rating, ws etc and the code of the function objective_func
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!