필터 지우기
필터 지우기

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
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 CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by