how to re-run/continue the terminated inner while loop at nested while loop?
3 次查看(过去 30 天)
显示 更早的评论
Hello guys and gals also lovely admins + veteran warriors,i am a student who do small FEM project, and i would like to ask some ideas and guidance how to re-run the terminated inner while loop at nested while loop.
The idea is from Finite Element Method 2D Frame in simple form (base is fixed or pinned on the left, and the right side is either free or rolled support) with two single forces at different position, which is 2 (assume forces and position in same axis, for example in y axis). With crude explanation, given all initial position and the desired two ideal deflection position is known, the current deflection is obtained by calculating with two forces. The program is accomplished when both current deflection is near enough (in my program i call it 'corr' or correction relative) single ideal deflection for each nodes. The two forces will get calibrated (each force have increase and decrease in loops, depends on the value of each 'corr') according to the value of correction relative of each nodes.
The problem is, when one nodes is near enough ( corr >= 0.90 & corr<1) and other is not near enough (corr < 0.9), the one that satisfied first, program will be terminated (i'm using break feature).When the other one get calculated by obtained calibrated force, the deflection of the first node (the one that get the first satisfied enough) will change, the corr at first node also change. Personally i still didn't get the details of how to implemented this logic on matlab :(
the detail questions:
- How to re-run the inner while loop?
- how to re-run the while loop if the outer loop is the one that satisfied enough?
for getting initial idea of this, the following is single cycle force system of simple FEM 2D Frame and excel input&output, and not multi cycle system as i describe above, as i also still thinking about the logic of this kind of problem :(
thankyou guys and gals also lovely admins + veteran warriors, much love.
edit: don't forget to attach the files as 1 folder for run the program, thanks
%% the following is only part of the program, for full program yo can download the attached file(s)
calc = 1; %index for looping process
loop(calc) = 0; %pre-looping process
ideal_dp_1 = data2(:,7); %need input-change in the future
corr(calc)=abs((desg_defl_int)/(ideal_dp_1 - desg_pos_int))
%% PART 4: Looping part for generating force with correction error >= 90%
% Addiing looping force
while corr(calc) >= 0
calc = calc + 1
loop(calc)=loop(calc-1)+1
if corr < 0.90
act_f = act_f + act_fl_inc
elseif corr >= 0.9 & corr <1
act_f = act_f
disp('we got good force!')
else corr > 1
act_f = act_f + act_fl_dec
end
defl_loop_ans = kkk*act_f; %deflection toward acting dofs
%%% Mapping generated Deflection
% #1 Deflection & Acting Force data each dof
def_table_loop = zeros(big_dof,1); %empty matrix for after added force loop
for_table_loop = zeros(big_dof,1);
for mm=1:tot_act_dof;
dof_act=t_act_dof(mm,1);
def_value=defl_loop_ans(mm,1);
for_value=act_f(mm,1);
def_table_loop(dof_act,1)=def_table_loop(dof_act,1)+def_value;
for_table_loop(dof_act,1)=for_table_loop(dof_act,1)+for_value;
end
% #2 Deflection for each axis
defl = def_table_loop(:,1);
defl_x = defl(1:3:big_dof);
defl_y = defl(2:3:big_dof);
defl_theta = defl(3:3:big_dof);
% #3 Post-Deflect position
newp_x = pos_x+defl_x;
newp_y = pos_y+defl_y;
newp_theta = (pos_theta + defl_theta); %1 RAD = 57.296 DEG
%deflection position
all3defl_loop= zeros(big_nod,3);
all3defl_loop(:,1) = defl_x;
all3defl_loop(:,2) = defl_y;
all3defl_loop(:,3) = defl_theta
desg_defl_loop= all3defl_loop((round(data2(:,5)/3)),data2(:,4));
corr(calc)=abs((desg_defl_loop)/(ideal_dp_1 - desg_pos_int))
last_corr = corr(calc)
if last_corr >= 0.9 & last_corr < 1
disp('force calc is done!!')
break
end
end
3 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!