Stem(Array) is graphed wrong (off by one). Index error?
Ältere Kommentare anzeigen
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.
Antworten (1)
Azzi Abdelmalek
am 16 Feb. 2013
Bearbeitet: Azzi Abdelmalek
am 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)
Kategorien
Mehr zu Language Fundamentals finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!