写入二进制值到文件中MATLAB [英] writing binary values into file in MATLAB

查看:152
本文介绍了写入二进制值到文件中MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个图像文件转换成二进制的VHDL进行处理。而我是转换图像二进制和编写矩阵到一个文本文件中不必要的逗号number.I之间来到时,要vector.my输入一列是一个正方形matrix.all除了逗号part.i工作以及正在使用虚拟值。任何人都可以给任何建议。

  A = [1 3 6 9]。
B = DEC2BIN(A');
FNAME ='output.txt的';
FID = FOPEN('output.txt的','W');
dlmwrite(FNAME,B);

但输出文件是这样的

  0,0,0,1
0,0,1,1
0,1,1,0
1,0,0,1

我期待

  0001
0011
0110
1001


解决方案

您必须通过作为分隔符。参考: - dlmwrite使用

  dlmwrite('output.txt的',B'')

i was converting an image file into binary to process in VHDL. while i was converting image to binary and when writing that matrix into a text file unnecessary commas came between the number.I want a column vector.my input is a square matrix.all working well except the comma part.i am using dummy values.can anyone give any suggestions

a=[1 3;6 9];
b=dec2bin(a');
fName = 'output.txt';
fid = fopen('output.txt','w');
dlmwrite(fName, b);

but the output file was like this

0,0,0,1
0,0,1,1
0,1,1,0
1,0,0,1

i was expecting

0001
0011
0110
1001

解决方案

You have to pass '' as an delimeter . Ref:- dlmwrite usage

dlmwrite('output.txt', b, '')

这篇关于写入二进制值到文件中MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆