hello everyone. I would like to ask which part of the code written below is wrong. There are two steps: 1. Add a zero matrix of N rows and 2 columns to a matrix; 2. Remove the zero matrix of N rows and 2 columns from a matrix. Thank you very much.

2 views (last 30 days)
Wesley on 1 Jun 2021
Edited: darova on 1 Jun 2021
[ma,na] = size(dataC);
if ma>=mb
out1= zeros((ma-mb),2);
dataF(dataF==0)=[];
else
out2= zeros((mb-ma),2);
dataC1=[dataC;out2];%Add the 0 matrix of N rows and 2 columns to one block
dataF(dataF==0)=[];
end
%%%%%%%%%%%%%%%%%%%The coordinate dataG of the same point in datae and dataF%%%%%%%%%%%%%%%%%
[mc,nc] = size(dataE);
[md,nd] = size(dataF);
if mc>=md
out3= zeros((mc-md),2);
dataF1=[dataF;out3];%Add the 0 matrix of N rows and 2 columns to one block
dataG=intersect(dataE,dataF1);
dataG(dataG(1,:)==0)=[];
else
out4= zeros((mc-md),2);
dataE1=[dataE;out4];%Add the 0 matrix of N rows and 2 columns to one block
dataG=intersect(dataE1,dataF);
dataG(dataG(1,:)==0)=[];
end

Wesley on 1 Jun 2021
dataC(dataC==[0,0])=[];
Using this code, the original matrix is changed from two columns to one, and how to correct it.