What about storing the values in vectors? Then there is no need to stop the loop:
n = length(A);
P_in = zeros(1, n);
z_in = zeros(1, n);
D_in = zeros(1, n);
inlet_i = 0;
for i = 1:2:n-1
line_desc = A{i};
line_data = str2num(A{i+1});
switch line_desc
case 'inlet'
inlet_i = inlet_i + 1;
P_in(inlet_i) = line_data(1);
z_in(inlet_i) = line_data(2);
D_in(inlet_i) = line_data(3);
case ...
end
P_in = P_in(1:inlet_i);
z_in = z_in(1:inlet_i);
D_in = D_in(1:inlet_i);
Stopping scripts to manipulate the data is "meta-programming" and in consequence prone to errors and hard to debug.
Best Answer