how to solve scatterplot error in matlab

前端 未结 1 1000
有刺的猬
有刺的猬 2021-01-29 10:41

following is a part of the code I am writing,

for ii=1:length(k31)

B   = [k31(ii);k32(ii)];

X=abs( pinv(A)*B);

g1(ii)=X(1,:);

g2(ii)=X(2,:);

g3(ii)=X(3,:);         


        
相关标签:
1条回答
  • 2021-01-29 11:04

    You are feeding scatter with 4 arguments: scatter(X, Y, S, C). Your error states:

    C must be a single color, a vector the same length as X, or an M-by-3 matrix.

    meaning that the fourth argument g1 does not have the same dimensions as the first argument.

    What probably happened here is that you didn't re-initialize g1 before the loop, and so it retained its previous size. Put the following line before the for-loop:

    g1 = zeros(size(k31));
    

    and it should work.

    0 讨论(0)
提交回复
热议问题