Borrar filtros
Borrar filtros

simplify variable called with different source(different sheet excel), How?

3 visualizaciones (últimos 30 días)
Hello Everyone,
in this problem i want to call another source (sheet on excel, from second (data of 1st axis) to third (data for second axis)) which i painstackingly plan to make another variable and copy-paste code for this, but actually it's pretty much same line code and same function/variable. data generated by each sheet have different axis, so i have to separate it, with each axis. my generated data is in array and in many shapes. how to simplify this? code below is part of my line code i wrote. Attacment files is input excel and full code line i wrote
any suggestion for this problem and any part solved will help me a lot, thank you veterans.
edit: slimmed line code
data2=xlsread('input3d.xlsx',2);
data3=xlsread('input3d.xlsx',3); % <<<<<<< i want to clone code line for generating this input
%%%%%%%%%%% first part
% Force Loop System
tfl = rmmissing(data2(:,1));%total force loop
mfl_inc = zeros(b_dof,tfl); %for increase looping force
mfl_dec = zeros(b_dof,tfl); %for decrease looping force
%%% 'For Loop' looping each Cycle Force System
for p = 1:tfl
% for increase loop force
td_f1inc = length(rmmissing(data2(:,2+(p-1)*10)));
% cell data at row 2,12,22,32, ...
for u=1:td_f1inc
fdofl_ic = data2(u,2+(p-1)*10); %loop force DOFs
floop_ic = data2(u,3+(p-1)*10); %loop forces
mfl_inc(fdofl_ic,1+(p-1)) = floop_ic;
end
% for decrease loop force
td_f1dec = length(rmmissing(data2(:,4+(p-1)*10)));
for uu=1:td_f1dec
fdofl_dc = data2(uu,4+(p-1)*10);
fcalc_dc = data2(uu,5+(p-1)*10);
mfl_dec(fdofl_dc,1+(p-1)) = fcalc_dc;
end
end
act_f = matx_f(a_dof,:); %initial force(s)
afl_inc = mfl_inc(a_dof,:);%active force loop _ increase
afl_dec = mfl_dec(a_dof,:);%active force loop _ decrease
%%%%%%%%%%%% second part
%% PART 6: Looping part for generating force with tolerance >= 90%
% Addiing looping force
% matrix value tolerance
% matrix value defl pos loop, desg pos loop
m_deplo= zeros(3,tfl); % 1st row = axis
% 2nd row = DOF
% 3rd row = value
tol_value = zeros(1,tfl);%determine the lastest tolerance
calc = 0; %index for looping process
while true
rem_f = rem(calc,tfl)+1;
calc = calc + 1;
if m_tol(2,rem_f) < 0.90
act_f = act_f + afl_inc(:,rem_f);
elseif m_tol(2,rem_f) > 1
act_f = act_f + afl_dec(:,rem_f);
else % 0.9 <= v_tol(2,rem_f) < 1
act_f = act_f;
end
de_l_ans = kkk*act_f; %deflection toward acting dofs
%%% Mapping generated Deflection
% Deflection & Acting Force data each dof
de_l = zeros(b_dof,1); %empty matrix for after added force loop
f_l = zeros(b_dof,1);
for mm=1:toa_dof
dof_al = tra_dof(mm,1);
de_lv = de_l_ans(mm,1);
fl_val= act_f(mm,1);
de_l(dof_al,1) = de_l(dof_al,1)+de_lv;
f_l(dof_al,1)=f_l(dof_al,1)+fl_val;
%convert in manner of all DOFs condition,
%not only in active DOFs condition.
end
de_lx = de_l(1:6:b_dof);
de_ly = de_l(2:6:b_dof);
de_lz = de_l(3:6:b_dof);
de_th_lx = de_l(4:6:b_dof);
de_th_ly = de_l(5:6:b_dof);
de_th_lz = de_l(6:6:b_dof);
%deflection position, in terms of nodal
a6de_l = zeros(b_nod,6);
a6de_l(:,1) = de_lx;
a6de_l(:,2) = de_ly;
a6de_l(:,3) = de_lz;
a6de_l(:,4) = de_th_lx;
a6de_l(:,5) = de_th_ly;
a6de_l(:,6) = de_th_lz;
for o = 1:tfl
%%% defl axis, DOFs, and value
td_deplo=length(rmmissing(data2(:,7+(o-1)*10)));
% cell data at row 7,17,27,37,etc...
for w = 1:td_deplo
deplo_ax = data2(w,(6+(o-1)*10));
deplo_dof = data2(w,(7+((o-1)*10)));
deplo_pl = a6de_l((ceil(data2(:,7+((o-1)*10))/6)), ...
data2(:,6+((o-1)*10)));
m_deplo(1,o) = deplo_ax;
m_deplo(2,o) = deplo_dof;
m_deplo(3,o) = deplo_pl;
end
%%% tolerance
m_tol(1,:) = m_dp(2,:); %number of tollerance
tol_val = (m_deplo(3,o)/(m_idp(2,o)- m_dp(3,o)));
m_tol(2,1+(o-1)) = tol_val;
end
if all( m_tol(2,:) >= limit1 & m_tol(2,:) <= limit2)
disp('force calc is done!!')
break
end
end

Respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by