MATLAB: Fill matrix with zeros

arraysindexingmatrix arraymultiplicationzeros

Hello, i have two matrices, one has fixed size 100×1 and the second one changes lets say could be 97×4 or 103×4, i want to multiply just the first columns of these two, but how can i multiply them, i just want to fill the rest of the rows with zeros if its less than 100 ,and i want to remove the last three columns if it is more than 100, Any ideas? Thank you

Best Answer

A: is the Fixed Sized Matrix
B: is the Variable Sized Matrix
A(:,1) .* [B(1:min(size(A,1),size(B,1)),1); zeros(size(A,1)-size(B,1),1)]