フィルターのクリア

print leading and trailing zeros into text file

2 ビュー (過去 30 日間)
mia saam
mia saam 2017 年 11 月 4 日
コメント済み: Cedric 2017 年 11 月 4 日
hi I have this hex values 0BA12CE0 that I want to print to a text file ,uses these commands to do that :
fileID1 = fopen('enct40.txt','wt');
fprintf(fileID1,'%s\n',cd1);
fclosef(fileID1);
but when I open the text file the leading and trailing zeros are disappear like this 'BA12CE' how can I print the results as they are without any missing values ?
  3 件のコメント
per isakson
per isakson 2017 年 11 月 4 日
編集済み: per isakson 2017 年 11 月 4 日
This works here on R2016a,Win7
cd1 = '0BA12CE0';
fileID1 = fopen('enct40.txt','wt');
fprintf(fileID1,'%s\n',cd1);
fclose(fileID1);
type enct40.txt
output
0BA12CE0
mia saam
mia saam 2017 年 11 月 4 日
It's dec value=195112160 when I use dec2hex(195112160) the leading zero will disappear

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

採用された回答

Cedric
Cedric 2017 年 11 月 4 日
>> dec2hex(195112160, 8)
ans =
'0BA12CE0'
  2 件のコメント
mia saam
mia saam 2017 年 11 月 4 日
thank you so much
Cedric
Cedric 2017 年 11 月 4 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by