# problem using stem command

3 views (last 30 days)
Muhammad Haziq on 6 Dec 2018
Commented: Star Strider on 6 Dec 2018
Hi,
I want to plot some point by using stem comand but I recieve error. can any body guide me. point are lev_press and I need to mark them in between rec_start and rec_stop.
error:
Subscript indices must either be real positive integers or logicals.
Error in example (line 87)
stem(x,lev_press(1,r),':diamondr')
data
rec_start = 1.625608000000000e+03;
rec_stop=1.655613000000000e+03;
x = rec_start:1:rec_stop;
lev_press=[1629.599, 1630.297, 1633.178];
for r = lev_press 1:1:3
figure
stem(x,lev_press(1,r),':diamondr')
end

Star Strider on 6 Dec 2018
Try this:
rec_start = 1.625608000000000e+03;
rec_stop=1.655613000000000e+03;
lev_press=[1629.599, 1630.297, 1633.178];
x = linspace(rec_start, rec_stop, numel(lev_press));
figure
stem(x, lev_press)
grid
ylim([1600 1650]) % Optional (‘Zooms’ Plot)
The ylim call makes the slight variation in the ‘lev_press’ values more visible.

Star Strider on 6 Dec 2018
How are ‘rec_start’, ‘rec_stop’, and ‘lev_press’ related? Are they themselves times, or something else?
I have no idea what your data represent, or what you want to do.
I am guessing. Try this:
rec_start = 1.625608000000000e+03;
rec_stop=1.655613000000000e+03;
lev_press=[1629.599, 1630.297, 1633.178];
x = linspace(rec_start, rec_stop, numel(lev_press));
figure
stem(lev_press, ones(size(lev_press)), 'filled')
grid
xlim([rec_start rec_stop])
text(rec_start, 0.05, sprintf('\\bf\\leftarrowStart'), 'HorizontalAlignment','left')
text(rec_stop, 0.05, sprintf('\\bfStop\\rightarrow'), 'HorizontalAlignment','right')
See if that does what you want.
Muhammad Haziq on 6 Dec 2018
Hi,
Thanks for the reply and helping me, this resolve my problem.
Regards,
Haziq
Star Strider on 6 Dec 2018
As always, my pleasure.