what this functions exactly do (fwrite) and (ubitN)?

9 ビュー (過去 30 日間)
Abduellah Elbakoush
Abduellah Elbakoush 2022 年 1 月 9 日
回答済み: Walter Roberson 2022 年 1 月 10 日
how I can use ubitN , and What does it do ?

採用された回答

John D'Errico
John D'Errico 2022 年 1 月 9 日
help ubitN
ubitN not found. Use the Help browser search field to search the documentation, or type "help help" for help command options, such as help for methods.
ubitN is not part of MATLAB, not is it in any MATLAB toolbox. You need to contact the source.
Ok, someone will surely tell me that ubitN is ubitiquous. ;) (Spelling intentional there.)
  2 件のコメント
Abduellah Elbakoush
Abduellah Elbakoush 2022 年 1 月 9 日
i use N here as Number 1,2,3 ect like ubit1, what dose it used for ?
Abduellah Elbakoush
Abduellah Elbakoush 2022 年 1 月 9 日
[msg,len_total]=fread(f_id,'ubit2');

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2022 年 1 月 10 日
When you use fread with precision 'ubit' followed by a number, such as 'ubit2' or 'ubit18', then fread reads the next number of bits specified by the number, and assigns each group of bits as an unsigned integer.
When you are reading more than one value in a single call, such as fread(f_id, [1 10], 'ubit2') then fread treats the input as a stream of bits. In the case of this example, the first 2 bits would go to the first output element, the next 2 bits would go to the second output element, and so on.
However, each time that you do a new fread(), you are alway starting at the beginning of a byte, and at the end of the fread() with a 'ubit*' specification, if there are any unused bits in the last byte that has been read in, then those bits are discarded. You cannot for example use do 'ubit3', 'ubit4', 'ubit9' in order to split the first 16 bits as 3 bits, then 4 bits, then 9 bits: when you end the 'ubit3' call, the 5 remaining bits in the first byte are discarded; then when you end the 'ubit4' call, the 4 remaining bits in the current (second in the file) byte are discarded, then the 8 bits from the next byte and the 1st bit from the byte after that would be read in, and the 7 bits at the end would be discarded.. for a total of 4 bytes read, with a number of the internal bits being discarded. But fread(f_id, [1 4], 'ubit4') would be happy to read 4 bits, 4 bits, 4 bits, 4 bits, for a total of 16 bits with no bits discarded -- the discarding is at the end of each call to fread()

yanqi liu
yanqi liu 2022 年 1 月 10 日
編集済み: Walter Roberson 2022 年 1 月 10 日
yes,sir,may it use in parameter precision,such as
'*ubit18'
means:
'ubit18=>uint32'

Community Treasure Hunt

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

Start Hunting!

Translated by