How to do a stem plot for a 4x100 vector value?

Hi Yall Im very rusty with matlab and Im still quite lost on how to do this
I have this code right now, it woked when i only had one traffic, but now i have 4, all but into the vector x, but I dont know how to seperatly do them all, I know I will need a for loop but thats it, I tried to look up how, but Ive come up short.
N=4; %Nodes number
G=1.0; %Total traffic intensity
p=G/N; %Traffic intensity per node
Tics=100; %The number or clock ticks to simulate
x=rand(N,Tics)<p; %This vector will hold the traffic
stem(x)
ylim([0 1.5])
xlim([0 100])

 採用された回答

Chunru
Chunru 2022 年 9 月 20 日
編集済み: Chunru 2022 年 9 月 20 日

0 投票

N=4; %Nodes number
G=1.0; %Total traffic intensity
p=G/N; %Traffic intensity per node
Tics=100; %The number or clock ticks to simulate
x=rand(N,Tics)<p; %This vector will hold the traffic
for i=1:N
subplot(N, 1, i)
stem(x(i, :))
ylim([0 1.5])
xlim([0 100])
end

2 件のコメント

Ethan Woodvine
Ethan Woodvine 2022 年 9 月 20 日
Thanks this is great to know!
But i need to make 4 seperate stem plots.
So subplot them. to show 4 seperate graphs is there a way to do that?
Chunru
Chunru 2022 年 9 月 20 日
See the updated.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeModeling についてさらに検索

製品

リリース

R2021b

タグ

質問済み:

2022 年 9 月 20 日

コメント済み:

2022 年 9 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by