Im new to MatLab and am using pre-existing code to perform a simple task of making a bar chart. Im getting an error message that says, "Must supply Y data or X and Y data as first argument(s)."
My code:
figure
[sort,I]=sortrows('lastoil',-1);
bar(sort);
My variables are defined in this picture below. What am I doing wrong?

 Respuesta aceptada

Image Analyst
Image Analyst el 22 de Jul. de 2015
Editada: Image Analyst el 22 de Jul. de 2015

0 votos

Don't use sort as a variable name - it's a built-in function. Call it sortedValues. ALso, pass it some data (lastoil), not a string ('lastoil').
[sortedValues, sortOrder] = sortrows(lastoil, -1);
bar(sortedValues, 'FaceColor', 'b', 'BarWidth', 1);
grid on;

1 comentario

Sonny  Wilson
Sonny Wilson el 22 de Jul. de 2015
This worked! I had to take lastoil out of quotation marks to get it working.
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 22 de Jul. de 2015

Comentada:

el 22 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by