How to add cell arrays?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Darsana P M
el 21 de Nov. de 2017
Comentada: Walter Roberson
el 21 de Nov. de 2017
IV={'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '01'}
The expected output is:
IV={'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '02'} ie only incrementing the value at the end??
What must be the matlab code?
0 comentarios
Respuesta aceptada
Walter Roberson
el 21 de Nov. de 2017
IV = {'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '01'};
y = {'00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '01'};
x_numeric = cellfun(@(x) sscanf(x, '%x'), IV);
y_numeric = cellfun(@(x) sscanf(x, '%x'), y);
xplusy_numeric = x_numeric + y_numeric;
xplusy_cell = sprintfc('%02x', xplusy_numeric);
... I predict you are going to change the question once you think about this for a few minutes.
2 comentarios
Walter Roberson
el 21 de Nov. de 2017
IV = {{'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '01'}};
y = {'00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '01'};
x_numeric = cellfun(@(x) sscanf(x, '%x'), IV{1});
y_numeric = cellfun(@(x) sscanf(x, '%x'), y);
for K = 2 : 3
x_numeric = x_numeric + y_numeric;
IV{K} = sprintfc('%02x', x_numeric);
end
Now look at IV{1}, IV{2}, IV{3}
... and I still predict that you are going to change the question once you think about it for a few minutes.
Más respuestas (0)
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!