i have an array of 16*16 of fixed point hexadecimal and i want to store it in coe file as 1D values

1 次查看(过去 30 天)
0a9eb 06666 03c3c 06666
03c3c 0d8df 06666 06666
0a9eb 0a9eb 0d8df 03c3c
03c3c 03c3c 0a9eb 06666

回答(1 个)

Walter Roberson
Walter Roberson 2019-11-23
Assuming a cell array of character vectors, you can
cellfun(@dec2hex, YourCellArray)
and post process that however is suitable for your situation.
  2 个评论
Duaa Basman
Duaa Basman 2019-11-23
this an array of size 16*16 include fixed point values in which one bit for integer and 16 bit for fraction and i want to save this values in coe file to use it in fpga
Walter Roberson
Walter Roberson 2019-11-23
%reference: https://www.xilinx.com/support/documentation/sw_manuals/xilinx11/cgn_r_coe_file_syntax.htm
fid = fopen('YourOutput.coe', 'w');
fprintf(fid, 'memory_initialization_radix=16;\n');
fprintf(fid, 'memory_initialization_vector=\n');
for row = 1 : size(YourCellArray,1)
for col = 1 : size(YourCellArray,2)-1
fprintf(fid, '%s ', YourCellArray({row, col}));
end
if row == size(YourCellArray,1)
fprintf(fid, '%s;\n', YourCellArray{row,end});
else
fprintf(fid, '%s\n', YourCellArray{row,end});
end
end
fclose(fid);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Standard File Formats 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by