Setting a plot's x-axis by units and not finer data points?

1 回表示 (過去 30 日間)
No No
No No 2021 年 9 月 7 日
回答済み: Steven Lord 2021 年 9 月 7 日
I have a simple issue but I can't seem to ask the right question to find it on Google or this community.
I have the data for a function over 10 seconds, recorded in 10 ms steps. This leaves me with 10000 data points.
When I plot it, the x axis uses the data points and goes from 1 to 10000, but I would like the axis ticks to be for seconds, not thousands of seconds.
What's the easiest way to fix this?

回答 (1 件)

Steven Lord
Steven Lord 2021 年 9 月 7 日
When you call plot with one data input, the indices of the elements in the vector are used as the X coordinates.
plot((1:10).^2, '-o') % uses 1:10 as the X coordinates
When you call plot with two data inputs, the first is used as the X coordinates and the second the Y coordinates.
plot(11:20, (1:10).^2, '-o') % uses 11:20 as the X coordinates

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by