# 符号付固定小数点型f​iオブジェクトの行列​を16進数でCSV出​力する方法を教えてく​ださい。

9 views (last 30 days)
K_S_ on 20 Jul 2022
Commented: K_S_ on 20 Jul 2022

64ビット符号付固定小数点型fiオブジェクトの行列(１×100のembedded.fi) a_fi があります。
これを16進数でcsv出力する方法を教えていただきたいです。よろしくお願いいたします。
a = randn(1,100);
T = numerictype(true,64,60);
F = fimath('OverflowMode', 'saturate',...
'RoundMode', 'round',...
'SumMode', 'FullPrecision',...
'ProductMode', 'FullPrecision',...
'MaxProductWordLength', 256,...
'MaxSumWordLength', 256);
a_fi = fi(a,T,F);

Hernia Baby on 20 Jul 2022
hex関数をお使いください
a = fi((magic(3)/10), 1, 16, 12);
b = hex(a)
b = 3×18 char array
'0ccd 019a 099a' '04cd 0800 0b33' '0666 0e66 0333'
##### 2 CommentsShow NoneHide None
Hernia Baby on 20 Jul 2022
Edited: Hernia Baby on 20 Jul 2022

a = randn(1,100);
T = numerictype(true,64,60);
F = fimath('OverflowMode', 'saturate',...
'RoundMode', 'round',...
'SumMode', 'FullPrecision',...
'ProductMode', 'FullPrecision',...
'MaxProductWordLength', 256,...
'MaxSumWordLength', 256);
a_fi = fi(a,T,F);
b_fi = hex(a_fi)
b_fi = 'e8ac848756136e00 07bfd3df111af600 0ee24ab18d83d600 08114bd09d7fe880 f1a11f12245d3d80 f8f9133f2c401f40 208cb57352767200 1288fcc13a0a2300 fd6b8ea7247cb4a0 f95bf16bbff6bfc0 0d2a1642b65f9980 0a84f535ae77af00 0b4c134e46aa2100 f5d080902194c700 f80de9579eb16280 1b3bdbad2ff8a300 10d5de3cdfe9c100 13d2cce41cc30500 0b07b00e73d91d00 f6254c36474d5e80 2413a60ab0663a00 f86881df56050140 fce90682ebb0f120 db95ffe687336e00 1860c5e1ea313f00 f75791d09378d100 fd6fcb4f8a7e4ac0 0eba38122816a880 ef29e03d7e097100 0acac847a2522800 ef9af86328cdc900 fff904f4f05fba0e 122c91f660c7a400 f088167634162980 eada17b5ea132c00 06b95d5d1c0cb140 f63b78f443842580 fcc22e610151bb00 feb94fb1dbe6d240 1895b5ae7c7c1900 07bb41f9454cfd80 f089a9a7ce00bd80 fca181bdf33d8280 1b28288e9daf1f00 17d7bc278e10c500 fce077a8074357a0 e3980a0fab39ef00 00a5057dc0fea4a8 ee230f295625aa00 0fed1a89da188c80 f9b5f4303fc71340 e8e4fde141079600 fbcb6f9f65754540 08d7fd3b7a951500 e89ef2a57744e300 16c161de536bb900 04996b7ba6b73200 f50e80f586482880 efb9e25f34592600 ff414a3180168bd0 10740338163bfa00 e834ab67adc75a00 fe0e3fc5ca0ebd30 034c791d2907aaa0 13e79e6251ba4200 1ee3e194189f7900 0966e12d261c2780 143e3c501d859b00 1e94182b4da96200 11ac15754caedb00 199d2e91dad0b000 f6f0f4a402b63000 eea35ff6096d8e00 19dceefd4ab68900 f4112630ebcadd00 0b7130f8bc945e80 ed980dfa15168f00 fea3b6513d94cc70 fad719f95a656ac0 0cc86ed1e803b780 0e677605fe178200 18b60147f02ee200 04d4fa8079554e80 00dc999f79a6af10 0696fe44a06e5600 1003ef9d254fa000 02bc16b3bfe4dec0 271798f8fa52ca00 f1c3f0ff0454c700 09b8d2657006e180 e5bdd7762c151100 f739d0ad0e9cde80 e484333d8028dd00 12942327216d1d00 feaa9fb8bbb5b850 0b1aa15a23f06a00 0540a49d7a2e1540 fe51349dc52f86d0 17df3fdc8e741000 19365b45d6b17d00'
■書き込みに関して
b_fiはchar型になっています
csv出力する場合はいくつか考えられます
writematrixのDelimiterオプションを'space'にする
writematrix(b_fi,'b_fi.csv','Delimiter','space')
②文字をcell分割する
b_fi1 = split(b_fi,' ')'
b_fi1 = 1×100 cell array
{'e8ac848756136e00'} {'07bfd3df111af600'} {'0ee24ab18d83d600'} {'08114bd09d7fe880'} {'f1a11f12245d3d80'} {'f8f9133f2c401f40'} {'208cb57352767200'} {'1288fcc13a0a2300'} {'fd6b8ea7247cb4a0'} {'f95bf16bbff6bfc0'} {'0d2a1642b65f9980'} {'0a84f535ae77af00'} {'0b4c134e46aa2100'} {'f5d080902194c700'} {'f80de9579eb16280'} {'1b3bdbad2ff8a300'} {'10d5de3cdfe9c100'} {'13d2cce41cc30500'} {'0b07b00e73d91d00'} {'f6254c36474d5e80'} {'2413a60ab0663a00'} {'f86881df56050140'} {'fce90682ebb0f120'} {'db95ffe687336e00'} {'1860c5e1ea313f00'} {'f75791d09378d100'} {'fd6fcb4f8a7e4ac0'} {'0eba38122816a880'} {'ef29e03d7e097100'} {'0acac847a2522800'} {'ef9af86328cdc900'} {'fff904f4f05fba0e'} {'122c91f660c7a400'} {'f088167634162980'} {'eada17b5ea132c00'} {'06b95d5d1c0cb140'} {'f63b78f443842580'} {'fcc22e610151bb00'} {'feb94fb1dbe6d240'} {'1895b5ae7c7c1900'} {'07bb41f9454cfd80'} {'f089a9a7ce00bd80'} {'fca181bdf33d8280'} {'1b28288e9daf1f00'} {'17d7bc278e10c500'} {'fce077a8074357a0'} {'e3980a0fab39ef00'} {'00a5057dc0fea4a8'} {'ee230f295625aa00'} {'0fed1a89da188c80'} {'f9b5f4303fc71340'} {'e8e4fde141079600'} {'fbcb6f9f65754540'} {'08d7fd3b7a951500'} {'e89ef2a57744e300'} {'16c161de536bb900'} {'04996b7ba6b73200'} {'f50e80f586482880'} {'efb9e25f34592600'} {'ff414a3180168bd0'} {'10740338163bfa00'} {'e834ab67adc75a00'} {'fe0e3fc5ca0ebd30'} {'034c791d2907aaa0'} {'13e79e6251ba4200'} {'1ee3e194189f7900'} {'0966e12d261c2780'} {'143e3c501d859b00'} {'1e94182b4da96200'} {'11ac15754caedb00'} {'199d2e91dad0b000'} {'f6f0f4a402b63000'} {'eea35ff6096d8e00'} {'19dceefd4ab68900'} {'f4112630ebcadd00'} {'0b7130f8bc945e80'} {'ed980dfa15168f00'} {'fea3b6513d94cc70'} {'fad719f95a656ac0'} {'0cc86ed1e803b780'} {'0e677605fe178200'} {'18b60147f02ee200'} {'04d4fa8079554e80'} {'00dc999f79a6af10'} {'0696fe44a06e5600'} {'1003ef9d254fa000'} {'02bc16b3bfe4dec0'} {'271798f8fa52ca00'} {'f1c3f0ff0454c700'} {'09b8d2657006e180'} {'e5bdd7762c151100'} {'f739d0ad0e9cde80'} {'e484333d8028dd00'} {'12942327216d1d00'} {'feaa9fb8bbb5b850'} {'0b1aa15a23f06a00'} {'0540a49d7a2e1540'} {'fe51349dc52f86d0'} {'17df3fdc8e741000'} {'19365b45d6b17d00'}

writecell(b_fi1,'b_fi1.csv')
K_S_ on 20 Jul 2022

### Categories

Find more on Fixed-Point Designer in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!