How can I temporarily pause a for loop, extract data at that point, and then continue the script? Here is my code:
A = importdata('HW8.2.Custom1.txt','%f%f%f', ' ',1);n=length(A); for i = 1:2:n-1 line_desc = A{i}; line_data = str2num(A{i+1}); if strcmp(line_desc,'inlet'); P_in = line_data(1); z_in = line_data(2); D_in = line_data(3); elseif strcmp(line_desc,'exit'); P_out = line_data(1); z_out = line_data(2); D_out = line_data(3); elseif strcmp(line_desc,'fitting'); K_L = line_data(1); V = line_data(2); Element_Num = line_data(3); elseif strcmp(line_desc,'pipe'); L = line_data(1); D = line_data(2); rough = line_data(3); delta_z = line_data(4); Element_Num = line_data(5); elseif strcmp(line_desc,'pump'); H_s = line_data(1); Element_Num = line_data(2); else strcmp(line_desc,'turbine'); H_s = line_data(1); Element_Num = line_data(2); end end
What I am trying to do is stop the for loop each i, make variables based on that i, and then continue the loop and repeat for each iteration. Right now, however, it is just running the whole for loop and then giving me variables based on the final iteration (when i = n-1) Is it possible to pause it after each iteration and what function would I use?
Best Answer