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?

 채택된 답변

Image Analyst
Image Analyst 2015년 7월 22일
편집: Image Analyst 2015년 7월 22일

0 개 추천

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

Sonny  Wilson
Sonny Wilson 2015년 7월 22일
This worked! I had to take lastoil out of quotation marks to get it working.
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2015년 7월 22일

댓글:

2015년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by