I'm keep getting " index exceeds matrix dimension"

2 次查看(过去 30 天)
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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by