Deleting Spaces in an Hex Array

3 ビュー (過去 30 日間)
tinkyminky93
tinkyminky93 2022 年 6 月 2 日
回答済み: Arjun 2024 年 11 月 8 日 6:07
Hello,
I have an array like
[AA BB CC DD EE] and i want to see it like [AABBCCDDEE]. how can i do it? Thank you
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 6 月 2 日
Is it a string() array? A cell array of character vectors? A categorical array? Or is it currently coded in terms of 0xAA in the input?
Jan
Jan 2022 年 6 月 2 日
"Hex Array" is not existing class of Matlab. Is this a CHAR vector or String?
Then deleting spaces is easy:
A = 'AA BB CC DD EE'
B = A(~isapce(A))
% Or
B = A(A ~= ' ')

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

回答 (1 件)

Arjun
Arjun 2024 年 11 月 8 日 6:07
I see that you have an array which contains some space separated hexadecimal numbers and you want to remove the spaces between them.
To do so you can use the “strrep” function of MATLAB to replace the spaces present in the array by empty strings.
Kindly refer to the documentation of “strrep” for better understanding: https://www.mathworks.com/help/releases/R2022a/matlab/ref/strrep.html
For the scenario provided here is how you can use “strrep”:
% Original array with spaces
hexArray = 'AA BB CC DD EE';
% Remove spaces using strrep
hexArrayNoSpaces = strrep(hexArray, ' ', '');
% Display the result
disp(hexArrayNoSpaces);
AABBCCDDEE
I hope this will help!

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by