Stem(Array) is graphed wrong (off by one). Index error?
Mostra commenti meno recenti
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.
Risposte (1)
Azzi Abdelmalek
il 16 Feb 2013
Modificato: Azzi Abdelmalek
il 16 Feb 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)
Categorie
Scopri di più su Language Fundamentals in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!