%% |While| Loop Pattern
% In this example, a flow chart combines transitions and connective
% junctions to construct a |while| loop that computes the greatest common
% divisor of the inputs. 

% Copyright 2020 The MathWorks, Inc.

%%

model = 'sf_while';
load_system(model);
open_system([model '/While Loop']);

%%
% The loop in this flow chart is equivalent to this
% snippet of C code:
% 
%  while(q > 0) { 
%      r = fmod(p,q); 
%      p = q; 
%      q = r; 
%  }