Filter löschen
Filter löschen

How to put strings on the x axes

8 Ansichten (letzte 30 Tage)
Seyhan Emre Gorucu
Seyhan Emre Gorucu am 31 Mai 2012
Kommentiert: Nathaniel Werner am 25 Aug. 2017
Hello,
I want to plot types of methods vs their corresponding numbers. That is, X axes will be string and Y axes will be numbers. Currently, my matrix is cell as below:
neworder =
'N2' [0.1700]
'HC' [0.1700]
'SAGD' [0.1800]
'Steamflood' [0.4500]
'CSS' [0.4500]
'hot Water' [0.4500]
'CO2' [0.5100]
'Polymer' [0.6300]
'ASP' [0.6300]
'Combustion' [0.6500]
I tried to plot string vs. numbers. It didn't work out. Basically, my X axes is the first column and Y axes is the second column.
Thank you,

Akzeptierte Antwort

Oleg Komarov
Oleg Komarov am 31 Mai 2012
neworder = {
'N2' [0.1700]
'HC' [0.1700]
'SAGD' [0.1800]
'Steamflood' [0.4500]
'CSS' [0.4500]
'hot Water' [0.4500]
'CO2' [0.5100]
'Polymer' [0.6300]
'ASP' [0.6300]
'Combustion' [0.6500]}
bar([neworder{:,2}])
set(gca,'XtickL',neworder(:,1))
  2 Kommentare
Matt
Matt am 9 Jan. 2017
With Matlab R2016a I need to use 'XtickLabel'
Nathaniel Werner
Nathaniel Werner am 25 Aug. 2017
I have a similar problem.
I am trying to do this in my code
data_strings = {...
'-[(u^\prime\cdot\nabla)\omega_r^\prime]^*' [-2.5 -1.6 -1. -2.1 -1.25 -0.85]...
'[(\omega^\prime\cdot\nabla)u_r^\prime]_\perp^*' [0.15 0.05 0.01 2.2 1.04 0.5]...
'[(\omega^\prime\cdot\nabla)u_r^\prime]_{||}^*' [0.3 0.25 0.1 -1.3 -0.65 -0.62]...
'[-(2\Omega\cdot\nabla)u_r^\prime]^*' [0.87 0.7 0.77 1 0.81 0.79]
'[\nu\nabla^2\omega_r^\prime]^*' [0.6 0.42 0.3 0.12 0.17 0.05]};
But I keep getting the following error.
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Is there a way I can make this work?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Thomas
Thomas am 31 Mai 2012
figure1 = figure;
axes1 = axes('Parent',figure1,'XTickLabel',neworder(:,1));
box(axes1,'on');
hold(axes1,'all');
% Create plot
plot(cell2mat(neworder(:,2)));
or
bar(cell2mat(neworder(:,2)))

Kategorien

Mehr zu Migrate GUIDE Apps 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!

Translated by