フィルターのクリア

How do I plot data points with x-axis tick labels that are strings?

18 ビュー (過去 30 日間)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017 年 9 月 18 日
コメント済み: Walter Roberson 2024 年 3 月 16 日
hello there, i have 15 (x) points named x1 to x15; and corresponding to this i have 15 (y) points named from y1 to y15. how can i plot them ?
  4 件のコメント
Marylyn Sammut
Marylyn Sammut 2022 年 1 月 14 日
how can you do it with plot(data, ‘.’, (signalNoise,signalTime)
Walter Roberson
Walter Roberson 2022 年 1 月 15 日
編集済み: Walter Roberson 2022 年 1 月 24 日
I have the suspicion that you might be attempting to plot variables in a table() object. No currently released version of MATLAB supports that directly; you would need to instead
plot(data.signalTime, data.signalNoise, '.')

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2023 年 8 月 29 日
編集済み: MathWorks Support Team 2023 年 8 月 29 日
The easiest way to specify the tick labels as strings is to use the xticklabels function. For example, plot five points. Change the ticks to only five values by calling the xticks function. Then change the x-axis tick labels to “x1”, “x2”, “x3”, “x4”, and “x5”. 
plot(1:5) 
xticks(1:5) 
xticklabels(["x1", "x2", "x3", "x4", "x5"]) 
Another way to combine a character with a sequence of numbers is to use the xtickformat function. 
plot(1:5) 
xticks(1:5) 
xtickformat("x %g ") 
Alternatively, you can plot categorical values. Specify the second argument when you call the “categorical” function to ensure that the data is in the expected order. 
x = categorical(["Red", "Yellow", "Blue"],["Red", "Yellow", "Blue"]);
plot(x,1:3)
  11 件のコメント
AD
AD 2023 年 5 月 8 日
What if we have large number of data points..say 70?
How can I then obtain a plot in matlab?
Walter Roberson
Walter Roberson 2023 年 5 月 8 日
Please read http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval for information about why we strongly recommend against creating variable names dynamically.

サインインしてコメントする。

その他の回答 (1 件)

ejjada
ejjada 2024 年 3 月 16 日
plz anyone answer me
how to read my hole x axis data as x1,x2,x3,x4,...

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by