corresponding legends for each curves in one plot
显示 更早的评论
Hi !
I'm trying to plot 8 matrixes (C1 to C8) on 1 plot. For each ploted matrix, I want the corresponding legend (C1 to C8). Below is my code and when I run it, MATLAB returns me :
"Function 'subsindex' is not defined for values of class 'cell'.
Error in matlab_common_plot (line 16) legend(Legend)"
numberfile = 8
figure
title('Spannung vs. Traversenweg - - C')
for i=1:numberfile
mat_x=eval(['C',num2str(i)]);
plot(mat_x(:,2),mat_x(:,6),'-')
hold all
end
hold off
xlabel('Traversenweg (mm)')
ylabel('Spannung (MPa)')
Legend = cellstr( num2str((1:numberfile)','C%d') );
legend(Legend)
saveas(gca, 'Spannung vs. Traversenweg - -C.jpg', 'jpg');
close
end
采纳的回答
更多回答(1 个)
Romain Marchant
2015-10-13
4 个评论
clear legend
And check that you have not used legend as a variable anywhere in your program. But if you have so, rename it.
And please use the comment function instead of posting your comments as a new answer.
Romain Marchant
2015-10-13
编辑:Romain Marchant
2015-10-13
Thorsten
2015-10-13
Romain, please formally accept my answer and then open a new question to ask a new question.
Romain Marchant
2015-10-13
类别
在 帮助中心 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!