How to graphically represent man in MATLAB
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello
I implemented the river problem in MATLAB and used the following function to graphically represent this problem (which Nora Khaled was kind enough to draw for me).
As you can see, people are represented in the problem with these shapes
shapes=['+' '^' 'x' 's' '*' 'd' '|' '_'];
I wanted to ask if it is possible to present this issue in a better way and with better symbols ??
function[]=Enve(A,B)
%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=A;
right= B;
% 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
shapes=['+' '^' 'x' 's' '*' 'd' '|' '_'];
leftcounter=1;
rightcounter=1;
for i=1:1:nL+nR
if left(i) ==1
scatter(pL(leftcounter,1),pL(leftcounter,2),shapes(i),'SizeData',200)
alpha(.5)
leftcounter=leftcounter+1;
else
scatter(pR(rightcounter,1),pR(rightcounter,2),shapes(i),'SizeData',200)
alpha(.5)
rightcounter=rightcounter+1;
end
end
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!