What is wrong with this MATLAB code?

前端 未结 4 600
情深已故
情深已故 2020-12-21 07:19

I am trying to do following in MATLAB,

global a b c d e f g h l;
A=[1 3;3 2];
B=[a 0;0 b];
C=[d 0;e f];
Ctranspose=transpose(C);
D=[sqrt(d) 0;0 sqrt(f)];
E=C         


        
4条回答
  •  情歌与酒
    2020-12-21 08:06

    In addition to everything mentioned here, please do format the code nicely (note: the code below is the OP's code, so it's programmatically wrong):

    global a b c d e f g h l;
    A = [1 3; 3 2];
    B = [a 0; 0 b];
    C = [d 0; e f];
    Ctranspose = transpose(C);
    D = [sqrt(d) 0; 0 sqrt(f)];
    E = Ctranspose / D;
    Etranspose = transpose(E);
    K = A + E;
    M = E * D * Etranspose;
    
    for a = 1:10
        for b = 1:10
            if  K == M
                print(a);
                print(b);
                print(d);
                print(e);
                print(f);
            end
        end
    end
    

    This spares you time and mental resources when reading your code, which actually takes much more time than writing it.

提交回复
热议问题