Stem(Array) is graphed wrong (off by one). Index error?
Afficher commentaires plus anciens
Hello This is my first post. I have created, using hist, a 1row-by-20col array with 20 numbers:
C=[.9 .1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]. This means that at position 0, the value is .9. At position 1 the value is .1 and so on. When I try to plot this array with the function "stem(C)" The graph would put the .9 value on x=1 and .1 value on x=2. It's supposed to go on x=0 and x=1 respectively. I've read about how Mathlab index starts with 1 instead of 0. Can anyone help me correct the graph? Thank you.
Réponses (1)
Azzi Abdelmalek
le 16 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 16 Fév 2013
C=[.9 .1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
stem(0:19,C,'r')
stem(C) % you did not specify the x-axis value. The default is 1:numel(C)
Catégories
En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!