matlab - Efficiently Interpolating along one dimension of a 5D Matrix -


the following code need , cannot figure out more efficient way this. need interpolate along 1 dimension of 5d matrix. can please enlighten me on how in matlab more efficiently? thanks!

    % define parameters     beta = 11000;     desired_soc = 0.55;      u1_length = 15;     u2_length = 3;     u3_length = 2;     x2_length = 2;     x3_length = 6;     x1_grid = [0.4:0.05:0.8]';       % not data, sufice     table_x1 = repmat(x1_grid,[1, x2_length,x3_length,u1_length,u2_length,u3_length]);     j_star = beta*(x1_grid - desired_soc).^2;      tic;     soc_state_penalty = single(zeros(x1_length,x2_length,x3_length,u1_length,u2_length,u3_length));     x2 = 1:x2_length         x3 = 1:x3_length             u1 = 1:u1_length                  u2 = 1:u2_length                       u3 = 1:u3_length                         f  = griddedinterpolant(x1_grid,j_star(:,x2,x3),'linear');  % need penalize soc                         soc_state_penalty(:,x2,x3,u1,u2,u3) = f(table_x1(:,x2,x3,u1,u2,u3));                       end                  end             end         end      end     toc; 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -