How to put strings on the x axes

5 visualizaciones (últimos 30 días)
Seyhan Emre Gorucu
Seyhan Emre Gorucu el 31 de Mayo de 2012
Comentada: Nathaniel Werner el 25 de Ag. de 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,

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 31 de Mayo de 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 comentarios
Matt
Matt el 9 de En. de 2017
With Matlab R2016a I need to use 'XtickLabel'
Nathaniel Werner
Nathaniel Werner el 25 de Ag. de 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?

Iniciar sesión para comentar.

Más respuestas (1)

Thomas
Thomas el 31 de Mayo de 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)))

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by