I have a cell array of strings (length = 4):
A = {'a', 'b', 'c', 'd'}
I have a double matrix of indices (length = 4):
B = [2, 4, 6, 8]
How can I create a new cell array C (of strings) of length = 8, that uses the indices in B to place the strings from A into the new array C. For any index not specified in B, I want to enter a ' ' space (empty string). Note: my real data does not go "every-other".
C = {' ', 'a', ' ', 'b', ' ', 'c', ' ', 'd'}
How can this be done in Matlab?
4+4, or is it the maximum index inB?A,B, andCwere arbitrary, except that the lengths ofAandBneed to be equal (because the indices inBcorrespond to the strings inA).B=[100 200 300 400]?Bcould be[100, 200, 300, 400], but then my new cell arrayCwould need to be at least length = 400 or greater.