MATLAB Answers


how to plot with respect to time insted of samples

on 7 Jan 2013


i have sensor which gives voltage output based on change in radiant temperature, the plot i am doing now is voltage signal in y axis and samples per trigger in x axis,

i want it to change the x axis to time.

plz anyone help.


Walter Roberson
on 7 Jan 2013

How are you plotting against samples per trigger? That is normally a fixed quantity. Are you experimenting with changing the number of samples you gather at one time ?

on 15 Jan 2013

number of samples are not being changed 1000 samples per trigger are considered

i am able to plotting the acquired voltage value against 1000 samples .i want the ploting for voltage v/s time.


No products are associated with this question.

2 Answers

Answer by Lalit Patil on 7 Jan 2013
Edited by Lalit Patil on 7 Jan 2013
 % Assign figure(1) to your V against samples program.. Then
 V = your data
 T = 1:100 % specify time unit


Answer by Walter Roberson
on 15 Jan 2013

Ah, your current x axis is not samples per trigger: it is sample number within the buffer.

So change your code to keep track of the number of times you have previously sampled. Then if you know your sampling frequency FS in Hz, use

Previous_Triggers = 0;    %before loop
%in loop
t = (Previous_Triggers * Samples_Per_Trigger + (0:Samples_Per_Trigger-1)) ./ FS;
plot(t, V);
Previous_Triggers = Previous_Triggers + 1;


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!