FSE 无损压缩的代码matlab

时间: 2024-04-09 10:25:30 浏览: 9
FSE(Finite State Entropy)是一种无损压缩算法,它基于有限状态机的原理。下面是一个使用Matlab实现FSE无损压缩的示例代码: ```matlab function compressed_data = fse_compress(data) % 初始化有限状态机 state = 0; bitstream = []; % 遍历输入数据 for i = 1:length(data) symbol = data(i); % 更新有限状态机 if state == 0 if symbol == 0 state = 1; bitstream = [bitstream, 0]; else state = 2; bitstream = [bitstream, 1]; end elseif state == 1 if symbol == 0 state = 3; bitstream = [bitstream, 0]; else state = 4; bitstream = [bitstream, 1]; end elseif state == 2 if symbol == 0 state = 5; bitstream = [bitstream, 0]; else state = 6; bitstream = [bitstream, 1]; end elseif state == 3 if symbol == 0 state = 7; bitstream = [bitstream, 0]; else state = 8; bitstream = [bitstream, 1]; end elseif state == 4 if symbol == 0 state = 9; bitstream = [bitstream, 0]; else state = 10; bitstream = [bitstream, 1]; end elseif state == 5 if symbol == 0 state = 11; bitstream = [bitstream, 0]; else state = 12; bitstream = [bitstream, 1]; end elseif state == 6 if symbol == 0 state = 13; bitstream = [bitstream, 0]; else state = 14; bitstream = [bitstream, 1]; end elseif state == 7 if symbol == 0 state = 15; bitstream = [bitstream, 0]; else state = 16; bitstream = [bitstream, 1]; end elseif state == 8 if symbol == 0 state = 17; bitstream = [bitstream, 0]; else state = 18; bitstream = [bitstream, 1]; end elseif state == 9 if symbol == 0 state = 19; bitstream = [bitstream, 0]; else state = 20; bitstream = [bitstream, 1]; end elseif state == 10 if symbol == 0 state = 21; bitstream = [bitstream, 0]; else state = 22; bitstream = [bitstream, 1]; end elseif state == 11 if symbol == 0 state = 23; bitstream = [bitstream, 0]; else state = 24; bitstream = [bitstream, 1]; end elseif state == 12 if symbol == 0 state = 25; bitstream = [bitstream, 0]; else state = 26; bitstream = [bitstream, 1]; end elseif state == 13 if symbol == 0 state = 27; bitstream = [bitstream, 0]; else state = 28; bitstream = [bitstream, 1]; end elseif state == 14 if symbol == 0 state = 29; bitstream = [bitstream, 0]; else state = 30; bitstream = [bitstream, 1]; end elseif state == 15 if symbol == 0 state = 31; bitstream = [bitstream, 0]; else state = 32; bitstream = [bitstream, 1]; end elseif state == 16 if symbol == 0 state = 33; bitstream = [bitstream, 0]; else state = 34; bitstream = [bitstream, 1]; end elseif state == 17 if symbol == 0 state = 35; bitstream = [bitstream, 0]; else state = 36; bitstream = [bitstream, 1]; end elseif state == 18 if symbol == 0 state = 37; bitstream = [bitstream, 0]; else state = 38; bitstream = [bitstream, 1]; end elseif state == 19 if symbol == 0 state = 39; bitstream = [bitstream, 0]; else state = 40; bitstream = [bitstream, 1]; end elseif state == 20 if symbol == 0 state = 41; bitstream = [bitstream, 0]; else state = 42; bitstream = [bitstream, 1]; end elseif state == 21 if symbol == 0 state = 43; bitstream = [bitstream, 0]; else state = 44; bitstream = [bitstream, 1]; end elseif state == 22 if symbol == 0 state = 45; bitstream = [bitstream, 0]; else state = 46; bitstream = [bitstream, 1]; end elseif state == 23 if symbol == 0 state = 47; bitstream = [bitstream, 0]; else state = 48; bitstream = [bitstream, 1]; end elseif state == 24 if symbol == 0 state = 49; bitstream = [bitstream, 0]; else state = 50; bitstream = [bitstream, 1]; end elseif state == 25 if symbol == 0 state = 51; bitstream = [bitstream, 0]; else state = 52; bitstream = [bitstream, 1]; end elseif state == 26 if symbol == 0 state = 53; bitstream = [bitstream, 0]; else state = 54; bitstream = [bitstream, 1]; end elseif state == 27 if symbol == 0 state = 55; bitstream = [bitstream, 0]; else state = 56; bitstream = [bitstream, 1]; end elseif state == 28 if symbol == 0 state = 57; bitstream = [bitstream, 0]; else state = 58; bitstream = [bitstream, 1]; end elseif state == 29 if symbol == 0 state = 59; bitstream = [bitstream, 0]; else state = 60; bitstream = [bitstream, 1]; end elseif state == 30 if symbol == 0 state = 61; bitstream = [bitstream, 0]; else state = 62; bitstream = [bitstream, 1]; end elseif state == 31 if symbol == 0 state = 63; bitstream = [bitstream, 0]; else state = 64; bitstream = [bitstream, 1]; end elseif state == 32 if symbol == 0 state = 65; bitstream = [bitstream, 0]; else state = 66; bitstream = [bitstream, 1]; end elseif state == 33 if symbol == 0 state = 67; bitstream = [bitstream, 0]; else state = 68; bitstream = [bitstream, 1]; end elseif state == 34 if symbol == 0 state = 69; bitstream = [bitstream, 0]; else state = 70; bitstream = [bitstream, 1]; end elseif state == 35 if symbol == 0 state = 71; bitstream = [bitstream, 0]; else state = 72; bitstream = [bitstream, 1]; end elseif state == 36 if symbol == 0 state = 73; bitstream = [bitstream, 0]; else state = 74; bitstream = [bitstream, 1]; end elseif state == 37 if symbol == 0 state = 75; bitstream = [bitstream, 0]; else state = 76; bitstream = [bitstream, 1]; end elseif state == 38 if symbol == 0 state = 77; bitstream = [bitstream, 0]; else state = 78; bitstream = [bitstream, 1]; end elseif state == 39 if symbol == 0 state = 79; bitstream = [bitstream, 0]; else state = 80; bitstream = [bitstream, 1]; end elseif state == 40 if symbol == 0 state = 81; bitstream = [bitstream, 0]; else state = 82; bitstream = [bitstream, 1]; end elseif state == 41 if symbol == 0 state = 83; bitstream = [bitstream, 0]; else state = 84; bitstream = [bitstream, 1]; end elseif state == 42 if symbol == 0 state = 85; bitstream = [bitstream, 0]; else state = 86; bitstream = [bitstream, 1]; end elseif state == 43 if symbol == 0 state = 87; bitstream = [bitstream, 0]; else state = 88; bitstream = [bitstream, 1]; end elseif state == 44 if symbol == 0 state = 89; bitstream = [bitstream, 0]; else state = 90; bitstream = [bitstream, 1]; end elseif state == 45 if symbol == 0 state = 91; bitstream = [bitstream, 0]; else state = 92; bitstream = [bitstream, 1]; end elseif state == 46 if symbol == 0 state = 93; bitstream = [bitstream, 0]; else state = 94; bitstream = [bitstream, 1]; end elseif state == 47 if symbol == 0 state = 95; bitstream = [bitstream, 0]; else state = 96; bitstream = [bitstream, 1]; end elseif state == 48 if symbol == 0 state = 97; bitstream = [bitstream, 0]; else state = 98; bitstream = [bitstream, 1]; end elseif state == 49 if symbol == 0 state = 99; bitstream = [bitstream, 0]; else state = 100; bitstream = [bitstream, 1]; end elseif state == 50 if symbol == 0 state = 101; bitstream = [bitstream, 0]; else state = 102; bitstream = [bitstream, 1]; end elseif state == 51 if symbol == 0 state = 103; bitstream = [bitstream, 0]; else state = 104; bitstream = [bitstream, 1]; end elseif state == 52 if symbol == 0 state = 105; bitstream = [bitstream, 0]; else state = 106; bitstream = [bitstream, 1]; end elseif state == 53 if symbol == 0 state = 107; bitstream = [bitstream, 0]; else state = 108; bitstream = [bitstream, 1]; end elseif state == 54 if symbol == 0 state = 109; bitstream = [bitstream, 0]; else state = 110; bitstream = [bitstream, 1]; end elseif state == 55 if symbol == 0 state = 111; bitstream = [bitstream, 0]; else state = 112; bitstream = [bitstream, 1]; end elseif state == 56 if symbol == 0 state = 113; bitstream = [bitstream, 0]; else state = 114; bitstream = [bitstream, 1]; end elseif state == 57 if symbol == 0 state = 115; bitstream = [bitstream, 0]; else state = 116; bitstream = [bitstream, 1]; end elseif state == 58 if symbol == 0 state = 117; bitstream = [bitstream, 0]; else state = 118; bitstream = [bitstream, 1]; end elseif state == 59 if symbol == 0 state = 119; bitstream = [bitstream, 0]; else state = 120; bitstream = [bitstream, 1]; end elseif state == 60 if symbol == 0 state = 121; bitstream = [bitstream, 0]; else state = 122; bitstream = [bitstream, 1]; end elseif state == 61 if symbol == 0 state = 123; bitstream = [bitstream, 0]; else state = 124; bitstream = [bitstream, 1]; end elseif state == 62 if symbol == 0 state = 125; bitstream = [bitstream, 0]; else state = 126; bitstream = [bitstream, 1]; end elseif state == 63 if symbol == 0 state = 127; bitstream = [bitstream, 0]; else state = 128; bitstream = [bitstream, 1]; end elseif state == 64 if symbol == 0 state = 129; bitstream = [bitstream, 0]; else state = 130; bitstream = [bitstream, 1]; end elseif state == 65 if symbol == 0 state = 131; bitstream = [bitstream, 0]; else state =

相关推荐

最新推荐

recommend-type

setuptools-0.6b3-py2.4.egg

Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
recommend-type

Java项目之jspm充电桩综合管理系统(源码 + 说明文档)

Java项目之jspm充电桩综合管理系统(源码 + 说明文档) 2 系统开发环境 4 2.1 Java技术 4 2.2 JSP技术 4 2.3 B/S模式 4 2.4 MyEclipse环境配置 5 2.5 MySQL环境配置 5 2.6 SSM框架 6 3 系统分析 7 3.1 系统可行性分析 7 3.1.1 经济可行性 7 3.1.2 技术可行性 7 3.1.3 运行可行性 7 3.2 系统现状分析 7 3.3 功能需求分析 8 3.4 系统设计规则与运行环境 9 3.5系统流程分析 9 3.5.1操作流程 9 3.5.2添加信息流程 10 3.5.3删除信息流程 11 4 系统设计 12 4.1 系统设计主要功能 12 4.2 数据库设计 13 4.2.1 数据库设计规范 13 4.2.2 E-R图 13 4.2.3 数据表 14 5 系统实现 24 5.1系统功能模块 24 5.2后台功能模块 26 5.2.1管理员功能 26 5.2.2用户功能 30 6 系统测试 32 6.1 功能测试 32 6.2 可用性测试 32 6.3 维护测试 33 6.4 性能测试 33
recommend-type

基于JSP药品进货销售库存管理系统源码.zip

这个是一个JSP药品进货销售库存管理系统,管理员角色包含以下功能:管理员登录,进货管理,销售管理,库存管理,员工管理,客户管理,供应商管理,修改密码等功能。 本项目实现的最终作用是基于JSP药品进货销售库存管理系统 分为1个角色 第1个角色为管理员角色,实现了如下功能: - 供应商管理 - 修改密码 - 员工管理 - 客户管理 - 库存管理 - 管理员登录 - 进货管理 - 销售管理
recommend-type

基于JSP商品销售管理系统源码.zip

这个是一个JSP商品销售管理系统,管理员角色包含以下功能:管理员登录,管理员首页,用户管理,供应商管理,商品管理,入库管理,出库管理,系统公告管理,管理员信息修改等功能。用户角色包含以下功能:用户注册,用户登录,供应商管理,商品管理,入库管理,出库管理,系统公告查看,个人信息修改等功能。 本项目实现的最终作用是基于JSP商品销售管理系统 分为2个角色 第1个角色为管理员角色,实现了如下功能: - 供应商管理 - 入库管理 - 出库管理 - 商品管理 - 用户管理 - 管理员信息修改 - 管理员登录 - 管理员首页 - 系统公告管理 第2个角色为用户角色,实现了如下功能: - 个人信息修改 - 供应商管理 - 入库管理 - 出库管理 - 商品管理 - 用户注册 - 用户登录 - 系统公告查看
recommend-type

什么是mysql以及学习了解mysql的意义是什么

mysql
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解释minorization-maximization (MM) algorithm,并给出matlab代码编写的例子

Minorization-maximization (MM) algorithm是一种常用的优化算法,用于求解非凸问题或含有约束的优化问题。该算法的基本思想是通过构造一个凸下界函数来逼近原问题,然后通过求解凸下界函数的最优解来逼近原问题的最优解。具体步骤如下: 1. 初始化参数 $\theta_0$,设 $k=0$; 2. 构造一个凸下界函数 $Q(\theta|\theta_k)$,使其满足 $Q(\theta_k|\theta_k)=f(\theta_k)$; 3. 求解 $Q(\theta|\theta_k)$ 的最优值 $\theta_{k+1}=\arg\min_\theta Q(
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。