MATLAB: How to match Date and Data of different length

datedifferent length

Hi, I have the following Two Date vectors (A & B) and one Data vector (C). The data in vecot C is correspond to Date in B. Now I wanna create anotehr data vector (D) which will be correspond to Date vector (A) but the data for missing date will be 0. For example:
A=[736546 736547 736548 736549 736550 736551 736552 736553 736554 736555]
B=[736546 736549 736552 736554 736555]
C=[4 5 9 7 3]
D=[ 4 0 0 5 0 0 9 0 7 3]
How to create the Vector D, with given vector A,B & C?

Best Answer

>> D = zeros(1,numel(A));
>> [idx,idy] = ismember(A,B);
>> D(idx) = C(idy(idx))
D =
4 0 0 5 0 0 9 0 7 3