Multiple bar graph with strange issue

Hello,
I'm facing strange issue while plotting multiple bar graph I used below code, which shows an error "Error using bar (line 168)
The length of X must match the number of rows of Y." FYI this code already available on Matlab Help center and I tried on live editor and it works fine there (but to me it gives error).
x = [1:24];
x1=randi([-5,5],1,24); % I suppose it.
x2=randi([-6,6],1,24); % I suppose it.
vals = [x1; x2];
b = bar(x,vals);
Secondly, I didn't give up and tried another code to plot . But this isn't intended plot (FYI: I need a pair of bar plots on single x tick and a little space between two x ticks). Can you help me out. Thanks in advance
x = [1:24];
x1=randi([-5,5],1,24);
x2=randi([-6,6],1,24);
bar(x1); hold on
bar(x2);

4 comentarios

Mathieu NOE
Mathieu NOE el 31 de Mzo. de 2021
hello
I have no problem to run your first code either with b = bar(x,vals); or b = bar(x,vals');
Don't you have another function "bar" in your path that is shadowing the native matlab function ?
shane watson
shane watson el 31 de Mzo. de 2021
@Mathieu NOE, I don't have anyother function related bar, not sure whats problem?
Mathieu NOE
Mathieu NOE el 31 de Mzo. de 2021
I am running the R2020b version - does yours suffers from a bug ? maybe you should contact TMW
Cris LaPierre
Cris LaPierre el 14 de Jun. de 2021
I was able to run your code. Are the resulting figures displayed above what you expected?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 31 de Mzo. de 2021

Comentada:

el 14 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by