So my output hexadecimal code is saved in a cell in the following format.
{'00 11 22 33 AA BB'}
I am trying to have it output as
{'1100 3322 BBAA'}
Any help would be greatly appreciated.

 採用された回答

Stephen23
Stephen23 2018 年 8 月 9 日
編集済み: Stephen23 2018 年 8 月 9 日

0 投票

This is easy with regexprep:
>> C = {'00 11 22 33 AA BB'};
>> regexprep(C,'(\w{2}) (\w{2})','$2$1')
ans =
'1100 3322 BBAA'

1 件のコメント

Scott Salazar
Scott Salazar 2018 年 8 月 9 日
Thank you so much! It worked like a charm.

サインインしてコメントする。

その他の回答 (1 件)

OCDER
OCDER 2018 年 8 月 9 日

0 投票

A = {'00 11 22 33 AA BB'; '00 11 22 3D AA BC'; '02 11 32 33 AA BB'};
A = cellfun(@(x) sprintf('%c%c%c%c %c%c%c%c %c%c%c%c', strrep(x, ' ', '')), A, 'un', false);
A =
3×1 cell array
'0011 2233 AABB'
'0011 223D AABC'
'0211 3233 AABB'

2 件のコメント

Stephen23
Stephen23 2018 年 8 月 9 日
Note that this does not return the order that the question requests.
OCDER
OCDER 2018 年 8 月 9 日
Doh, I didn't see that order change.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2018 年 8 月 9 日

コメント済み:

2018 年 8 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by