
Plot text with numbers
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivan Mich
am 8 Sep. 2020
Kommentiert: Star Strider
am 10 Sep. 2020
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?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 8 Sep. 2020
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 Kommentare
Weitere Antworten (1)
KSSV
am 8 Sep. 2020
Bearbeitet: KSSV
am 8 Sep. 2020
[num,txt,raw] = xlsread("test.xlsx") ; % can also use readtable
plot(num)
xticklabels(txt)
Siehe auch
Kategorien
Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!