MATLAB: Can anyone tell how to add ‘space’ in the library for the lzw compression technique
lzw compressionMATLAB
original:
after decompression:
as you can see the for the decompression the the space is not included in the paragraph can anyone tell me what should be include in the library for including space in the paragraph
Best Answer
LZW as a class of algorithms does not treat spaces as anything different from any other characters.
The bug is on line 17 of your code. Unless, that is, that line contains the character 'u': if it does then the bug is on line 25.
It has nothing to do withfprintf. As thestrcat clearly states,strcat removes whitespace characters from the end of char vectors:"For character array inputs,strcat removes trailing ASCII white-space characters". If you want to keep the space characters, put it into a scalar cell array, like this:
{' = '}
But really you would be much better off just writing a proper format string forfprintf, rather than using bothstrcat andfprintf.
strcat ignores trailing ASCII white space characters and omits all such characters from the output. White space characters in ASCII are space, newline, carriage return, tab, vertical tab, or form-feed characters, all of which return a true response from the MATLAB isspace function.Use the concatenation syntax [s1 s2 s3 ...] to preserve trailing spaces. strcat does not ignore inputs that are cell arrays of strings.
Best Answer