LZW编码算法matlab实现

上传人:汽*** 文档编号:568009677 上传时间:2024-07-23 格式:PDF 页数:4 大小:120.32KB
返回 下载 相关 举报
LZW编码算法matlab实现_第1页
第1页 / 共4页
LZW编码算法matlab实现_第2页
第2页 / 共4页
LZW编码算法matlab实现_第3页
第3页 / 共4页
LZW编码算法matlab实现_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《LZW编码算法matlab实现》由会员分享,可在线阅读,更多相关《LZW编码算法matlab实现(4页珍藏版)》请在金锄头文库上搜索。

1、-.LZW 编码算法,尝试使用matlab 计算%encoder LZW for matlab%yu 20170503clc;clear;close all;%初始字典dic = cell(512,1);for i = 1:256dici = num2str(i);end%输入字符串 a,按空格拆分成 A,注意加 1 对应围 1256a = input(input:,s);a = deblank(a);A = regexp(a,s+,split);L = length(A);for j=1:LAj = num2str(str2num(Aj)+1);endA_t = A1;%可识别序列B_t =

2、 test;%待验证词条d = 256;%字典指针b = 1;%输出指针B = cell(L,1);%输出初始output = ;%输出初始j=1;for j = 2:Lm=1;B_t =deblank(A_t, ,Aj);%合成待验证词条while(m = d)if strcmp(dicm,B_t)A_t = B_t;breakelsem=m+1;endendwhile(m = d+1)d = d+1;-.word.zl-.dicd = B_t;q=1;for q=1:dif strcmp(dicq,A_t)Bb = num2str(q);b = b+1;endendA_t = Aj;end

3、endfor q=1:d%处理最后一个序列输出if strcmp(dicq,A_t)Bb = num2str(q);b = b+1;endendfor n = 1:(b-1)Bn =num2str(str2num(Bn)-1);output=deblank(output, ,Bn);endoutput运算结果计算结果为 39 39 126 126 256 258 260 259 257 126LZW 解码算法,使用 matlab 计算%decoder LZW for matlab%yu 20170503-.word.zl.-.clc;clear;close all;%初始字典dic = cel

4、l(512,1);for i = 1:256dici = num2str(i);end%输入字符串 a,按空格拆分成 A,注意加 1 对应围 1256a = input(input:,s);a = deblank(a);A = regexp(a,s+,split);L = length(A);for j=1:LAj = num2str(str2num(Aj)+1);endB_t = A1;%待验证词条d = 256;%字典指针b = 1;%输出指针B = cell(L,1);%输出初始output = ;%输出初始j=1;Bb = char(dicstr2num(Aj);b = b+1;for

5、 j = 2:LBB = char(dicstr2num(Aj);B_d = regexp(BB,s+,split);%按空格拆分L_B = length(B_d);p=1;for p=1:L_BB(b+p-1) = B_dp;m=1;B_t =deblank(char(B_t), ,char(B_dp);%合成待验证词条while(m = d)if strcmp(dicm,B_t)B_t = B_t;breakelsem=m+1;end-.word.zl-.endwhile(m = d+1)d = d+1;dicd = B_t;B_t = B_dp;endendb = b+L_B;endfor n = 1:(b-L_B)Bn = num2str(str2num(Bn)-1);output=deblank(output, ,Bn);endoutput运算结果运算结果为 39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126-.word.zl

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号