Skip to content

Commit

Permalink
improved rectangular division
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev3nt1ne committed Jun 19, 2024
1 parent 61abf77 commit 6efab50
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion @hpc_lab/hpc_lab.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
%% Approximation
methods
[k0, k1, k2] = pws_ls_approx(obj, I, T, C, alp, alp_I0, using_voltage)
[lut, F, T] = pws_ls_offset(obj, ctrl, Vslot, Tslot, show )
[lut, F, T, M_var] = pws_ls_offset(obj, ctrl, Vslot, Tslot, show )
end

%% Graphs
Expand Down
39 changes: 26 additions & 13 deletions @hpc_lab/pws_ls_offset.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
function [lut, Vs, Ts] = pws_ls_offset(obj, ctrl, Vslot, Tslot, show )
function [lut, Vs, Ts, M_var] = pws_ls_offset(obj, ctrl, Vslot, Tslot, show )
%PWS_LS_OFFSET Summary of this function goes here
% Detailed explanation goes here

if ((nargin < 5) || isempty(show))
show = 0;
end

add_temp = 5;
add_temp = 0;

tmin = obj.t_outside;
tmax = obj.core_crit_temp + add_temp;

%Initially I need to craft a value table/surface
tsloti = 60;
tsloti = round(tmax-tmin);
%vsloti = 30;

% T:
Expand All @@ -25,6 +25,10 @@
F = obj.FV_table(:,3);
V = obj.FV_table(:,1);

%T = T(1:end-1);
%F = F(1:end-1);
%V = V(1:end-1);

h0 = ctrl.psac(1);
h1 = ctrl.psac(2);
h2 = ctrl.psac(3);
Expand Down Expand Up @@ -57,16 +61,23 @@
%matrix of initial variance:
% do not need it
%repeat until I have the exact number of columns and rows:
%row_dim = size(vtb, 1) -2;
%col_dim = size(vtb, 2) -2;
row_dim = size(vtb, 1);
col_dim = size(vtb, 2);
exc_ext = 1;
if exc_ext
row_dim = size(vtb, 1) -2;
col_dim = size(vtb, 2) -2;
else
row_dim = size(vtb, 1);
col_dim = size(vtb, 2);
end
og_row_dim = size(vtb, 1);
og_col_dim = size(vtb, 2);
%cidx = [1 1:col_dim col_dim];
%ridx = [1 1:row_dim row_dim];
cidx = 1:col_dim;
ridx = 1:row_dim;
og_col_dim = size(vtb, 2);
if exc_ext
cidx = [1 1:col_dim col_dim];
ridx = [1 1:row_dim row_dim];
else
cidx = 1:col_dim;
ridx = 1:row_dim;
end

sequential_merging = zeros(row_dim+col_dim-(Vslot+Tslot), 2);
sequential_merging_i = zeros(row_dim+col_dim-(Vslot+Tslot), 2);
Expand All @@ -79,7 +90,7 @@
storedVar = (og_row_dim)*(og_col_dim)*10;
mergeCR = [0 0];

B = [];
%B = [];
if (col_dim > Vslot)
ldx = ridx;
for i=1:(col_dim-1)
Expand Down Expand Up @@ -158,6 +169,7 @@
end

lut = zeros(Tslot, Vslot);
M_var = size(lut);

plridx = 1;
for i=1:row_dim
Expand All @@ -166,6 +178,7 @@
for j=1:col_dim
lcidx = find(cidx==j,1,"last");
lut(i, j) = mean(vtb(plridx:lridx, plcidx:lcidx), "all");
M_var(i,j) = var(vtb(plridx:lridx, plcidx:lcidx), 0, "all");
plcidx = lcidx+1;
end
plridx = lridx+1;
Expand Down

0 comments on commit 6efab50

Please sign in to comment.