Hello,
I have a question about a code. I have one file in which:
The first column has cell (text) arrays
The second has numbers (double)
In my plot x axis has text and y axis has numbers
I would like to plot x axis with y axis.
I am uploading this file.
How could I make it?

 Respuesta aceptada

Star Strider
Star Strider el 8 de Sept. de 2020

0 votos

Try this:
T1 = readtable('test.xlsx');
vars = T1.Properties.VariableNames;
figure
plot(T1{:,2})
Ax = gca;
Ax.XTick = 1:numel(T1{:,1});
Ax.XTickLabel = T1{:,1};
xlabel(vars{1})
ylabel(vars{2})
producing:
Note that table objects have specific indexing and variable reference requirements. The readtable function was introduced in R2013b.
.

2 comentarios

Ivan Mich
Ivan Mich el 10 de Sept. de 2020
Thank you very much !!!
Star Strider
Star Strider el 10 de Sept. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 8 de Sept. de 2020
Editada: KSSV el 8 de Sept. de 2020

0 votos

[num,txt,raw] = xlsread("test.xlsx") ; % can also use readtable
plot(num)
xticklabels(txt)

4 comentarios

Ivan Mich
Ivan Mich el 8 de Sept. de 2020
KSSV I am sorry but your solution is not working
Ivan Mich
Ivan Mich el 8 de Sept. de 2020
In x axis are showing numbers and NOT text
KSSV
KSSV el 8 de Sept. de 2020
Editada: KSSV el 8 de Sept. de 2020
See to it that ...the text should be all your text in cells....
T = readtable("test.xlsx") ;
plot(T.2)
xticklabels(T.1)
Ivan Mich
Ivan Mich el 8 de Sept. de 2020
KSSV I am sorry, but still not working

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.

Preguntada:

el 8 de Sept. de 2020

Comentada:

el 10 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by