似乎MATLAB的legend没有“追加”这个选项,就是说每次调用都会重新生成Legend,前面的全部刷掉。也有字符串矩阵的方法,可惜每行都要一样长操作不太方面。自己想了投机的一个办法来实现追加。
有若干曲线,都已经把object保存在了curve_obj{}中
每个曲线的名称保存在了curve_name{}中
于是用字符串生成的办法,先生成一个legend_command
然后用eval()函数调用这个生成的命令。
legend_command = ['legend(curve_obj, ''', curve_name{1}, ''''];
for i = 2 : curve_used_count % Construct the command the display a legend
legend_command = [legend_command, ',''', curve_name{i}, ''''];
end
legend_command = [legend_command, ')']
eval(legend_command);
其实这个方法也比较笨拙,希望有更好的方案,比如基于输入的字符矩阵的操作的。
有若干曲线,都已经把object保存在了curve_obj{}中
每个曲线的名称保存在了curve_name{}中
于是用字符串生成的办法,先生成一个legend_command
然后用eval()函数调用这个生成的命令。
legend_command = ['legend(curve_obj, ''', curve_name{1}, ''''];
for i = 2 : curve_used_count % Construct the command the display a legend
legend_command = [legend_command, ',''', curve_name{i}, ''''];
end
legend_command = [legend_command, ')']
eval(legend_command);
其实这个方法也比较笨拙,希望有更好的方案,比如基于输入的字符矩阵的操作的。