Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

Is there anything wrong in my matlab code? for p=1:m2m2frame2*8…

  1. User

    Is there anything wrong in my matlab code? for p=1:m2m2frame2*8 Vector_x_21{p}=[x(RBtensorQ{p}(2,1,1)),x(RBtensorQ{p}(2,1,2)),x(RBtensorQ{p}(2,1,3)),x(RBtensorQ{p}(2,1,4))];Vector_x_21_new{p}=Vector_x_21{p}; Vector_x_31{p}=[x(RBtensorQ{p}(3,1,1)),x(RBtensorQ{p}(3,1,2)),x(RBtensorQ{p}(3,1,3)),x(RBtensorQ{p}(3,1,4))];Vector_x_31_new{p}=Vector_x_31{p};

    X_Set2{p}=norm(Vector_x_21{p},'inf'); X_Set3{p}=norm(Vector_x_31{p},'inf');
    if R_wm_char(p)=='1' && X_Set2{p}-X_Set3{p}< T
        Qavg=(X_Set2{p}+X_Set3{p})/2;
        X_Set3_NEW1{p}=max(Qavg-T/2,0);
        if  X_Set3_NEW1{p}==Qavg-T/2
            X_Set2_NEW1{p}=Qavg+T/2;
        elseif X_Set3_NEW1{p}==0
            X_Set2_NEW1{p}=T;
        end
        X_Set2_diff1{p}=X_Set2_NEW1{p}-X_Set2{p};X_Set3_diff1{p}=X_Set3_NEW1{p}-X_Set3{p};
        [amax1,index1]=max(abs(Vector_x_21{p})); [amax2,index2]=max(abs(Vector_x_31{p}));
        if Vector_x_21{p}(1,index1)>=0
            Vector_x_21_new{p}(1,index1)=Vector_x_21{p}(1,index1)+X_Set2_diff1{p};
        elseif Vector_x_21{p}(1,index1)<0
            Vector_x_21_new{p}(1,index1)=Vector_x_21{p}(1,index1)-X_Set2_diff1{p};
        end
        if Vector_x_31{p}(1,index2)>=0
            Vector_x_31_new{p}(1,index2)=Vector_x_31{p}(1,index2)-X_Set3_diff1{p};
        elseif Vector_x_31{p}(1,index2)<0
            Vector_x_31_new{p}(1,index2)=Vector_x_31{p}(1,index2)+X_Set3_diff1{p};
        end        
               
    elseif R_wm_char(p)=='0' && X_Set2{p}-X_Set3{p}> -T 
        Qavg=(X_Set2{p}+X_Set3{p})/2;
        X_Set2_NEW2{p}=max(Qavg-T/2,0);
        if X_Set2_NEW2{p}==0
            X_Set3_NEW2{p}=T;
        elseif X_Set2_NEW2{p}==Qavg-T/2
            X_Set3_NEW2{p}=Qavg+T/2;
        end
        X_Set2_diff2{p}=X_Set2_NEW2{p}-X_Set2{p};X_Set3_diff2{p}=X_Set3_NEW2{p}-X_Set3{p};
        [amax1,index1]=max(abs(Vector_x_21{p})); [amax2,index2]=max(abs(Vector_x_31{p}));
        if Vector_x_21{p}(1,index1)>=0
            Vector_x_21_new{p}(1,index1)=Vector_x_21{p}(1,index1)-X_Set2_diff2{p};
        elseif Vector_x_21{p}(1,index1)<0
            Vector_x_21_new{p}(1,index1)=Vector_x_21{p}(1,index1)+X_Set2_diff2{p};
        end
        if Vector_x_31{p}(1,index2)>=0
            Vector_x_31_new{p}(1,index2)=Vector_x_31{p}(1,index2)+X_Set3_diff2{p};
        elseif Vector_x_31{p}(1,index2)<0
            Vector_x_31_new{p}(1,index2)=Vector_x_31{p}(1,index2)-X_Set3_diff2{p};
        end       
    end
    

    end

  2. Assistant

    There are no syntactical errors in your code. However, it is difficult to determine if the logic of the code is correct without knowing the specific requirements and inputs of your program.

  3. User

    can you help me to modify it ?

  4. Assistant

    Certainly! Please provide more information about what the code is supposed to do and what modifications you would like to make.