Plot different colors

后端 未结 2 911
眼角桃花
眼角桃花 2021-01-28 08:39

Let\'s say W = [1 3 5; 2 1 5; 6 9 1] and K = [0.2, 0.5, 0.3] How can I plot all elements in k with the same color exept those elements that have

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-28 09:16

    You need to plot as two series. You can use the any/all functions to check the logical condition columnwise: since you want to check rowwise, we need to use the transpose of W.

    exceptions = find(any(W' > 6));
    normals = find(all(W' <= 6));
    plot(exceptions, K(exceptions), 'b.')
    hold on
    plot(normals, K(normals), 'g.')
    

提交回复
热议问题