Hi, I have to draw a 'special grid' on a plot of a signal. Specifically, I need one vertical line after 8s and one 10s after the first (and then periodically in this order: 8s,10s,8s,10s etc etc..) How can I do this? I tried to use meshgrid but without results.
Thank you!

1 commentaire

dpb
dpb le 30 Oct 2016
Note the location in a time vector of some number of seconds will be
ix=round(T/dt);
where T is the set of desired times and dt the sample rate...

Connectez-vous pour commenter.

Réponses (1)

Riccardo Brambilla
Riccardo Brambilla le 30 Oct 2016

0 votes

Thank you both for your time; I solve the problem in this way!
t = [0:1:size(sx)-1]'./fs;
a = ceil(t(end));
x = [8:18:a];
y = [18:18:a];
z = [x;y];
z = z(:).';
plot(t,sx,t,dx);
legend('pupil sx', 'pupil dx');
ax = gca;
ax.XGrid = 'on';
ax.YGrid = 'off';
ax.XTickMode = 'manual'; % keep the same number of 'grid lines' even after resize
ax.XTick = z;
ax.XMinorTick = 'on';

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by