%This line creates the matrix and fills it with zeros
A = zeros(length(get(S.pp,'string')),length(get(S.ls,'string')));
%this line writes 1s to the matrix based on the currently selected items from the listbox and popupmenu
A(get(S.pp,'val'),get(S.ls,'val')) = 1;
So the idea is upon multiple calls to this popupmenu callback (eventually this will be in a button separate from the popupmenu)
append A instead of creating a new A everytime