How to add cell arrays?

1 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2017-11-21
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 个评论
Darsana P M
Darsana P M 2017-11-21
Sir, Actually i wanted to increment the cell array, IV, such that the output will be as follows:
IV 1= {'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '01'};
IV 2 = {'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '02'};
IV 3 = {'ca' 'fe' 'ba' 'be' 'fa' 'ce' 'db' 'ad' 'de' 'ca' 'f8' '88' '00' '03'};
and so on. Thanks for the reply.Is there a simpler way??
Walter Roberson
Walter Roberson 2017-11-21
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by