フィルターのクリア

How would I generate a plot like this when data is in excel file?

1 回表示 (過去 30 日間)
Bryan Tassin
Bryan Tassin 2021 年 8 月 28 日
コメント済み: Walter Roberson 2021 年 8 月 28 日
  1 件のコメント
Bryan Tassin
Bryan Tassin 2021 年 8 月 28 日
How do i make the x and y axis limits like that? Anyone??

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

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 8 月 28 日
In the case where you happen to have the Symbolic Toolbox available:
x = linspace(0,2*pi,50);
y = cos(tan(x.^2)+pi/2);
ax = gca;
plot(ax, x, y)
xtick_locations = (0:8)/4 * sym(pi);
xticks(ax, double(xtick_locations))
tickstrings = "$" + arrayfun(@latex, xtick_locations, 'uniform', 0) + "$";
xticklabels(ax, tickstrings);
ax.XAxis.TickLabelInterpreter = 'latex';
xlim([0, 2*pi])
If you do not have the Symbolic Toolbox, you can compute the tickstrings latex entries, but you need extra steps to account for the cases that should not show up as rational fraction times pi
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 28 日
MATLAB does not care where you get the data, so you should be thinking of dividing your work into three sections:
  1. Read the data from Excel
  2. Processing data that is in memory
  3. Plotting the results that are in memory
Do not think about it as having to process data that is in an excel file: think about it as getting excel data into memory and then a phase of processing data where the processing phase does not have to care how the data reached it.
To read data from Excel these days, use readmatrix() for uniform data, or readtable() for data of mixed datatype. xlsread() is not recommended these days.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by