Filter löschen
Filter löschen

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side

1 Ansicht (letzte 30 Tage)
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 Kommentar
Srivardhan Gadila
Srivardhan Gadila am 5 Apr. 2020
@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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by