Hi, I tried executing this loop,
colors = ['m';'y';'b';'g';'c']; loop_ind = 1; for k1 = 1:5 figure(4); linespec = colors(loop_ind); plot(x, y, linespec, 'LineWidth', 1);loop_ind = loop_ind + 1;hold onend legend('-0.02','-0.01','0','0.01','0.02')
But I get an error,
Attempted to access colors(6); index out of bounds because numel(colors)=5. Error in test_contact_ellipse (line 228)linespec = colors(loop_ind);
Now I'm getting the plot with the correct colors but the legend doesn't appear. How can I rectify this error.
Please give your suggestions.
Thanks
Best Answer