Info

This question is closed. Reopen it to edit or answer.

Plotting Graph that needs automated value for x-axis

1 view (last 30 days)
Jeb
Jeb on 29 Jan 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello.
I am working in plotting a graph where the y-axis is the data from the file I choose. However, for the x-axis, is it possible for matlab to automatically give 0.01 interval from the first value till the last value in the file and the file has no fixed amount of data.
Really appreciate if anyone can give some advice. Thanks!
Regards,
Jeb

Answers (1)

Geoff Hayes
Geoff Hayes on 29 Jan 2016
Jeb - how do you determine the first and last value in the file? If you know both, then you could do something like
firstValue = 1.0;
lastValue = 5.0;
x = firstValue:0.01:lastValue;
Since you are using the above to plot presumably as
plot(x,y)
then the number of elements (length) of x must be identical to the number of elements of y.
  1 Comment
Jeb
Jeb on 29 Jan 2016
Hey Geoff,
Thank you so much for your answer. In the file, it is a series of values that I selected based on the overall shape of the graph and only a small range are selected. Hence, there is no fixed first and last value for every set of file.
Again, thanks for answering.
Regards,
Jeb

Products

Community Treasure Hunt

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

Start Hunting!