How can i shift plot?

63 views (last 30 days)
Ege Tunç
Ege Tunç on 20 Apr 2019
Answered: Clay Swackhamer on 20 Apr 2019
I have a code i need to shift to right my plot by 1,2,3 and 5, respectively on x axis
p=[1/6 1/6 1/6 1/6 1/6 1/6];
q= conv(p,p)
r=conv(q,p)
rr=conv(r,p)
rrr=conv(rr,p)
rrrr=conv(rrr,p)
holdon
subplot(2,2,1),plot(p*100),xlabel('1 dice vs P(x)'),xlim([1,6]),legend('1 dice','P(x)')
holdon
次要情节(2 2 2),plot(q*100),xlabel('2 dices vs Q(x)'),xlim([1,13]),legend('2 dices','Q(x)')
holdon
subplot(2,2,3),plot(r*100),xlabel('3 dices vs R(x)'),xlim([1,19]),legend(“三个骰子”,'R(x)')
holdon
subplot(2,2,4),plot(rrrr*100),xlabel('6 dices vs S(x)'),xlim([1,37]),legend('6 dices','S(x)')

Accepted Answer

Clay Swackhamer
Clay Swackhamer on 20 Apr 2019
p=[1/6 1/6 1/6 1/6 1/6 1/6];
q= conv(p,p);
r=conv(q,p);
rr=conv(r,p);
rrr=conv(rr,p);
rrrr=conv(rrr,p);
subplot(2,2,1)
x1 = 2:1:length(p)+1;%shift by 1
plot(x1, p*100)
xlabel('1 dice vs P(x)')
xlim([1,7])
legend('1 dice')
次要情节(2 2 2)
x2 = 3:1:length(q)+2;%shift by 2
plot(x2, q*100)
xlabel('2 dices vs Q(x)')
xlim([1,15])
legend('2 dices')
subplot(2,2,3)
x3 = 4:1:length(r)+3;%shift by 3
plot(x3, r*100)
xlabel('3 dices vs R(x)')
xlim([1,22])
legend(“三个骰子”)
subplot(2,2,4)
x4 = 5:1:length(rrrr)+4;%shift by 5
plot(x4, rrrr*100)
xlabel('6 dices vs S(x)')
xlim([1,42])
legend('6 dices')
shifted plots.png

More Answers (0)

Tags

下载188bet金宝搏


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!