Create the x axis to my need

12 views (last 30 days)
David Peña
David Peña on 19 Mar 2022
Commented: Arif Hoq on 21 Mar 2022
Hello and thanks in advanced!
I´m having problems ploting some data I receive from an OBR. The problem is that the data I receive comes separated, on the one hand I have the y axis data (50x1 double) and on the other hand I have the x axis data (4096x1 double). The problem comes when I try to plot because if I try to decimate the graph I get is not perfect do to 4096 and 50 not been multiples.
So as the data received in the x axis is not important i have tried to create my own x axis and here is where my doubt is. I need this x axis to have the same length as the y axis so I can plot them together but the x axis must have every digit of the array separated 0.5 cm.
y = transpose((0:1:49));
xaxis = transpose((0:0.5:length(y)));

Accepted Answer

Arif Hoq
Arif Hoq on 20 Mar 2022
try this:
y = transpose((0:1:49));
xaxis = transpose(1:0.5:length(y)/2+1/2);
plot(xaxis,y)
  3 Comments
David Peña
David Peña on 21 Mar 2022
Thanks, it worked perfectly!
Arif Hoq
Arif Hoq on 21 Mar 2022
@David Peña please mark this question as a "Accepted answer"

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!