MATLAB: Adjust size of vector/matrix

reduce vector sizevector size;

Hello, How can I choose a vector array with first 50 elements? Eg: Say I have vector A with 1×50 dimension and B with 1×60. How can I make dimension of B same to A such that B will have first 50 elements? I tried using resample (B,50,60) but it seems that it choose 50 elements randomly, with some repetition. Is using imresize correct?
Any help will be appreciated.
Thank you in advance.

Best Answer

f you want to set the first 50 elements of B to be equal to A:
B(1:50) = A;
If you mean to delete excess elements in B until you get to the same size as A:
B = B(1:numel(A)); % this will turn B from 1x60 to 1x50,
% or whatever the number of elements in A is.