Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Bryan Tassin
Bryan Tassin el 28 de Ag. de 2021
Comentada: Walter Roberson el 28 de Ag. de 2021

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Ag. de 2021
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 comentario
Walter Roberson
Walter Roberson el 28 de Ag. de 2021
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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by