数学建模社区-数学中国
标题:
matlab 二进制写入问题
[打印本页]
作者:
lixuewei3
时间:
2017-4-10 11:02
标题:
matlab 二进制写入问题
- v* [' S1 O6 b, k3 Y
复制代码
在用matlab写入二进制遇到个问题,我写入的结果里面是十进制转换后的AScii码序列,但我实际要的是打开后是那种乱码的情况,如下图,不知道哪地方出问题了,小白
一个,还请帮忙
head=(['0xA6','0x00','0x51','0xff','0x01']);tail=uint8(['0x00','0xE6','0x28','0x9C','0x58']);
# Q6 g0 F5 m6 L3 |7 q
fid=fopen('C:\dzh365\USERDATA\block\自选股6.blk','w');
& ~$ X0 U: f, J: b& o2 U
fwrite(fid,head,'ubit8');
' B% n2 Q9 j _
code=[600000;300120;000467];
* _/ x2 o- n3 V9 q2 Z! R
for i=1:size(code,1)
# d1 q% m/ F8 x; O, Z* `
p=num2str(code(i,1));
3 ?! H, d0 _* \2 y8 [* q. b7 ~
uc=''; %定义一个空字符组
6 b. ]& y# O8 X" T% b
uc=strcat([uc,dec2hex('S'),dec2hex('Z')]);%%深圳股票
% f$ P) S/ |& O9 S: T: ~) N/ O
end
- D1 j8 c$ E; W5 H# V
if length(p)<6
& A' H5 B4 o6 k; e( O S
for add=1:(6-length(p))
: m' d7 `: L1 ]) M+ `
uc=strcat([uc,dec2hex('0')]);%=dec2hex(p(j));
7 V& y' U8 R8 n- B
end
' F; G- A, [/ L1 C# ~6 l- `
end
! X4 g2 ~' R( Q7 N
for j=1:length(p)
( \; e( s( K q; |* ^
%sprintf('%02x\n',p(j));%dec2hex(p(1))
, ~/ ]+ j5 \* p9 h A$ N9 H* ?
uc=strcat([uc,dec2hex(p(j))]);%=dec2hex(p(j));
- c, w$ o; q$ Z" H( z- l$ |/ K
end
& ^2 O( @; i0 V6 L4 W! t5 p
fwrite(fid,uc,'ubit8');
7 Q1 E) V; u5 Q
fwrite(fid,tail,'ubit8');
4 H8 A5 t& \: |+ n) C5 b6 B
end
; G! @/ j$ y& k! R! B6 {/ \" w3 Y5 ?9 j' ^
% D- r, X3 V+ S7 O
fclose(fid) %返回指针的值为0,则表示存储数据正常
) }' \4 z( S# j4 W$ X, h
复制代码
# w7 E+ \: \* A! g; b
作者:
lshqcable605
时间:
2017-5-9 13:58
啊啊啊啊啊啊啊
1 V0 ^) [9 W2 P8 A2 t0 X i
作者:
lshqcable605
时间:
2017-5-9 13:59
66666666666666666666666
3 V2 @ V# |0 u: r# a; b1 V
作者:
lshqcable605
时间:
2017-5-9 13:59
好好还好好还好好好好好
m9 O- N. }( E- |
作者:
lshqcable605
时间:
2017-5-9 13:59
666666666666666666666666666
% P8 ]) `$ }' @" B2 }9 S4 G0 N2 e
作者:
lshqcable605
时间:
2017-5-9 13:59
6666666666666666666
! S$ Y* }( s5 Z# n$ `* U2 s
作者:
lshqcable605
时间:
2017-5-9 14:00
好好还好好还好好好好好
) w: H# T; b5 y, y k, J" H
作者:
lshqcable605
时间:
2017-5-9 14:00
6666666666666666666666666666666666666666666
8 ^* l4 \3 v5 c# C6 H
作者:
lshqcable605
时间:
2017-5-9 14:01
999999999999999999999999999999999
# V" o r# s# z
作者:
lshqcable605
时间:
2017-5-9 14:01
6666666666666666666666
0 \- K7 u% Y9 Q$ K& C/ @; h
作者:
lshqcable605
时间:
2017-5-9 14:01
哈哈哈哈哈哈哈哈哈
# o7 }8 u) _& V7 {
作者:
lshqcable605
时间:
2017-5-9 14:01
2222222222222222221111111111111111
" ~; C& f% x) q" n% y1 [
作者:
lshqcable605
时间:
2017-5-9 14:01
好还好好还好好好好好好好好好
2 J7 z/ ]0 r- n
作者:
lshqcable605
时间:
2017-5-9 14:02
666666666666666666666
* A1 |! e$ {* I% k6 a6 w
作者:
lshqcable605
时间:
2017-5-9 14:02
9999999999999999999
`- R, Y" r- g% X" c( h
作者:
lshqcable605
时间:
2017-5-9 14:02
好好好还好好还好好好好好
' M4 ?1 ~$ r( m W9 X
作者:
lshqcable605
时间:
2017-5-9 14:02
66666666666666999999999999999999999999999
& R7 d# E8 j4 C. u
作者:
lshqcable605
时间:
2017-5-9 14:03
55555555555555666666666666666666666666666
/ D9 P- M$ t% q5 [3 f2 p
作者:
lshqcable605
时间:
2017-5-9 14:03
好好还好好还好好好好好
# e/ y( z& ^2 G/ f- b
作者:
lshqcable605
时间:
2017-5-9 14:03
和哈哈哈哈哈哈哈哈哈哈哈哈
2 M; v9 U" A- m: I, o* T( z; y
作者:
lshqcable605
时间:
2017-5-9 14:03
好还好好还好好好好好好好好好
9 s* T0 p# L+ \8 G- v( _2 E
作者:
lshqcable605
时间:
2017-5-9 14:04
好好还好好还好好好好好
7 P: ~$ Q, m8 i8 y
作者:
lshqcable605
时间:
2017-5-9 14:04
666666666666666666666666
7 x) `5 s% ?; t! P
作者:
lshqcable605
时间:
2017-5-9 14:04
99999999999999999999999
5 R8 _6 P4 |( o; l! z) s) T
作者:
lshqcable605
时间:
2017-5-9 14:04
蒙公网安备 15010502000194号
2 r9 D+ l3 ]& }. D' f
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5