MATLAB: How to solve this error horzcat Dimensions of matrices being concatenated are not consistent

dimensions of matrices being concatenated are not consistenterror horzcathorzcatMATLABmatrix array

Hi all, how can i solve this error:
t=Tp';
dt =t(2)-t(1);
vdrift = filter(d,drift)/dt;
delay=mean(grpdelay(d))
tt = t(1:end-delay);
vd = vdrift;
vd(1:delay) = [];
tt(1:delay) = [];
vd(1:delay) = [];
[pkp,lcp] = findpeaks(drift);
zcp = zeros(size(lcp));
[pkm,lcm] = findpeaks(-drift);
zcm = zeros(size(lcm));
figure,plot(t,drift,t([lcp lcm]),[pkp -pkm],'-',"LineWidth",2)
Error
Values of matrix are:

Best Answer

Hi Miguel,
When you type [var1 var2], you are concatenating horizontally, since your variables have different number of rows, you'll get an error.
This seems troublesome, I don't really understand what are you trying to do here, can you explain?
t([lcp lcm]),[pkp -pkm]
Related Question