Try this:
namesList = {'Sally', 'Fred', 'John'};
groceryList = cell(length(namesList), 2);
for n=1:quanShoppers
line1 = sprintf('Enter item for %s', namesList{n})
line2 = 'Enter price paid'
prompt = {line1; line2}
dlg_title = sprintf('Shopping list for %s', namesList{n})
userResponse = inputdlg(prompt, dlg_title, 1)
groceryList(n, 1) = namesList(n);
groceryList{n, 2} = userResponse{1};
groceryList{n, 3} = userResponse{2};
end
