怎么做matlab图例。。。关于legend的问题

http://zhidao.baidu.com/question/584034259250428405
我之前问你的问题。
我后来发现,这样获得的图例对应的字符必须数量相等,否者不行。
如何解决例如

clear;
clc;
str=[];
x=[0.1 1 10];
y=[0.1 1 10];
for i=1:3
for j=1:3
str=[str;['i=',num2str(x(i)),',j=',num2str(y(j))]];
end
end

这样错误提示是
??? Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.

Error in ==> loop_drawing_1 at 9
str=[str;['i=',num2str(x(i)),',j=',num2str(y(j))]];

我想输出图例的

改为用cell数组实现
clear;
clc;
figure;plot(rand(9,10));
x=[0.1 1 10];
y=[0.1 1 10];
for i=1:3
    for j=1:3 
   
       str{(i-1)*3+j} = ['i=' num2str(x(i)) ',j=' num2str(y(j))];
   end
end
legend(str)

追问

能不能解释下原因。。。。。多谢了。。。。我把悬赏提高
也顺便帮我看看这道题
http://zhidao.baidu.com/question/2203327840973365548.html

追答

理由很简单啊,数组或向量的元素必须同类型的变量,字符串等长度才行。而元胞数组没有这个限制.

来自:求助得到的回答
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答