MATLAB: Increment Nonce by any fixed value in loop

for loop

I have the nonce value in hex. Let say:
nonce = {'00' '11' '22' '33' '44' '55'};
I need to add any fixed value 'x'(hex) to this value in loop and need to save every new value.
I was doing this like:
nonce = {'00' '11' '22' '33' '44' '55'};
for i=1:5
nonce(i) = nonce + 01;
i = i+1;
end
But I am not acheiving what I need.

Best Answer

Using a loop:
nonce = {'00' '11' '22' '33' '44' '55'};
x = '01';
for i = 1:numel(nonce)
nonce{i} = dec2hex(hex2dec(nonce{i}) + hex2dec(x),2);
end
Or using cellfun:
nonce = {'00' '11' '22' '33' '44' '55'};
x = '01';
nonce = cellfun(@(y) dec2hex(hex2dec(y) + hex2dec(x),2),nonce,'uni',0);