MATLAB: How to display graphically

graphicsMATLAB

Hello
I want the conditions of an issue to be graphically displayed at each step of the program. For example, in the case of a River crossing puzzle, I want to show which people (variables) are on which side of the river at each step.
Thanks

Best Answer

not sure this is what you had in mind ...
%Environment
envSize=4;
figure;
x=-envSize:0.1:envSize;
y=.5*sin(x);
plot(y,x,'lineWidth',10)
axis([-envSize envSize -envSize envSize]);
hold on;
%Input
left=[0 0 1 1 1 1 1];
right= [1 1 0 0 0 0 0 0];
% number of ppl
nL=sum(left);
nR=sum(right);
%random position for ppl
maxX=envSize-1;
minX=2*max(y);
maxY=envSize-1;
minY=-(envSize-1);
pL = [-(minX + (maxX-minX) .* rand(nL,1)), (minY + (maxY-minY) .* rand(nL,1))]
pR = [(minX + (maxX-minX) .* rand(nR,1)) , (minY + (maxY-minY) .* rand(nR,1))]
% plot
scatter(pL(:,1),pL(:,2),'filled','SizeData',200)
alpha(.5)
scatter(pR(:,1),pR(:,2),'filled','SizeData',200)
alpha(.5)
the output looks like this