Draw a random polymer network by Matlab – a simple approach

A simple code can be used to depict the schematic diagram of the polymer network (to ease manual drawing).

clc,clear,close all

N = 200; % The length of chains.
P = 200; % The amount of chains.

% Random starting points.
x = rand(P,1) * 120 - 60; % The size of the box.
y = rand(1,P) * 120 - 60;

for p = 1:P
    xt = x(p);
    yt = y(p);
    for n = 1:N
        xt(n+1) = xt(n) + sind(rand * 360); % Growth angle.
        yt(n+1) = yt(n) + sind(rand * 360);
    end
    % Change the transperance of chains to show 2.5D effect.
    plot(xt, yt, 'Color', [0, 0, 0, rand])
    hold on
end

% Image properties.
xlim([-50 50])
ylim([-50 50])
xticks([])
yticks([])
axis square;
Example result of random polymer network
An example of the result.

By simple modification, a stretched network could also be produced.

Stretched network along Y
An example of stretched network (along Y).