how to implement in matlab

2 次查看(过去 30 天)
n=1011(binary) 11 in decimal and b= 3(decimal) and finally getting answer as 011(binary). the b LSB of n to produce the subexponential code of n. How to implement it in matlab?
n=1011 b=3 z=1|011 ans=011

采纳的回答

dpb
dpb 2013-8-7
编辑:dpb 2013-8-7
Ohh....I think I finally figured out what want--the (variable) number of LSB(its) of the input value...ok, if interpretation is correct.
r=bitand(n, bin2dec(repmat('1',1,b))); % value
r=dec2bin(bitand(n, bin2dec(repmat('1',1,b))),b); % bit representation
Use whatever integer is appropriate for the problem space; Matlab will work on default doubles if all are integers.
  25 个评论
Pooja
Pooja 2013-8-12
I think i am not able to make out the question.I have stored the output of the encoded binary stream as save temp.txt .And for decoding i am calling as load temp.txt.
dpb
dpb 2013-8-12
编辑:dpb 2013-8-15
I think i am not able to make out the question...
Clearly. We've had this problem from the very first question that I can't seem to get across to you the difference between internal representation and the conceptualization of what that representation means.
And the underlying issue is that whatever bits you calculate if they're stored in anything except a sequence of only that number of bits are then irretrievable as to which are/aren't actually data in the larger entity when the code length they represent isn't a fixed length.
So, instead of trying to explain verbally show some source code. It will have a precise meaning in a common language...from that starting point maybe we can finally reach a mutual understanding.
Post your Matlab code that does the calculation of the coding and the write...it can be the few lines needed to read in or generate an input array, the call of the coder that returns the encoded result and the subsequent write/save to the file. That should be able to be brought down to a half-dozen lines or so at most I'd think.
Then, for completeness show the encoding routine and the line or two necessary to read the file. Wouldn't hurt to add the first few lines (3 or 4, say) of the file as well.
I'm pretty sure this will show that you're saving each encoded result in an array element, either an integer or default double, in which case you have the problem I've outlined above.
Do you understand the comment I made time stamped 11 Aug 2013 at 15:50? In particular, do you understand the implications of the sentence from the paper quoted there? If not, we've got a hurdle to get you over to see why there's a problem here.
I'll repeat it here for a reminder--
... p. 26, the middle paragraph below the numbered steps of how to generate the code. Note carefully the penultimate sentence of that paragraph--
"Finally, the length of the produced code must be computed in order to properly transfer the coded value to the next stage." (emphasis added)
It's that length that isn't available if the data are passed as individual array elements--then they're all the length of the (internal) storage unit and the length of the code stored in the array element is unknown. Hence we (as the decoder) don't know and can't tell which is the first encoded bit within all the bits of the array element.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by