Help with dec2hex (case sensitive and Zero)

2 ビュー (過去 30 日間)
Raymond London
Raymond London 2018 年 2 月 21 日
コメント済み: Raymond London 2018 年 2 月 21 日
Hi everyone:
I have a problem related to the command dec2hex, I have issues with things like 0F where I wanted to be f, the problem with the 0 and with the capital F. Check the variables WhatIget and WhatIwant
I am attaching the code:
clc; clear;
CarsNum={'10','11','12','13','14','15','16','17'};
CarsDecimal=str2double(CarsNum);
CarsHex=dec2hex(CarsDecimal);
Pattern={'Car:Slot:'};
WhatIget=strcat(Pattern,CarsHex);
WhatIwant = {'Car:Slot:a','Car:Slot:b','Car:Slot:c','Car:Slot:d','Car:Slot:e','Car:Slot:f','Car:Slot:10','Car:Slot:11'};
I really appreciate your help.

採用された回答

C.J. Harris
C.J. Harris 2018 年 2 月 21 日
You could change the line:
CarsHex=dec2hex(CarsDecimal);
to:
CarsHex=lower(arrayfun(@(x) (dec2hex(x)), CarsDecimal, 'UniformOutput', false));
  1 件のコメント
Raymond London
Raymond London 2018 年 2 月 21 日
C.J
Perfect, very nice.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by