I'm keep getting " index exceeds matrix dimension"

2 views (last 30 days)
hey, I'm very new to matlab. We got an assignment to plot some data about ratings of cities in the USA, in 9 different catagories. (it is a famous data in MATLAB).
This is the assignment-
"Plot all the data for each city under one figure and add a legend containing category names. Use the xlabel, xlim, title, legend functions."
this is my code and the figure seems to come out right but i keep getting this warning- "In legend (line 118)
Index exceeds matrix dimensions."
r = figure(3);
hold on
for i= 1:size(names,1)
plot(ratings(:,i))
title('cities rankings by categories');
legend('climate','housing','health','crime','transportation','education','arts','recreation','economics');
xlabel('City ID');
xlim([0 329]);
end
I don't know what's the problem..cause I do get the figure.

Answers (0)

Community Treasure Hunt

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

Start Hunting!