且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我在Matlab图中需要不同的颜色

更新时间:2021-10-06 00:36:29

您用101行(零位)定义了变量conds,然后将4行更改为某些值.现在,您只想绘制这4条线,但是循环运行101次,因此它也绘制了零线.这就是您得到零行(实际上是97行...)的原因.这也是您在4条曲线上获得相同颜色(可能是各种图形颜色)在零线上浪费"的原因.

You defined the variable conds with 101 lines (of zeros), then changed 4 lines to some values. Now you want plotting only those 4 lines, but your loop runs 101 times, so it plots also the zero-lines. This is the reason you get a line at zero (actually 97 lines...). This is also the reason that you get same colors for the 4 curves, probably the variety of graph colors, "wasted" on the zero lines.

您只能使用

rows=[36 52 69 101] ;
color='rgbc'
for i=1:4
   plot (temp(1,:), cond(rows(i),:), 'color',color(i));
   hold on
end 
hold off

实际上,您根本不需要此conds=zeros(101,28),只需将将conds的值插入的行更正为:

Actually, you don't need this conds=zeros(101,28) at all, just correct the line that insert the values to conds to:

conds=cond([36 52 69 101],:);

而且,我认为您不需要在第一个循环中使用它.

And, I don't think you need it inside the first loop.