当前位置:网站首页>Matlab-创建文字云
Matlab-创建文字云
2022-07-27 09:57:00 【用户9925864】
之前用python制作过文字云(Python stylecloud制作酷炫的词云图),这次用matlab试一下
首先把内容准备到一个txt文件里面,本文以matlab的介绍为例子,使用 fileread 函数从txt中读取文本。
>> contents= fileread('matlab.txt');
>> contents
使用 string 函数将文本转换为字符串。然后,使用 splitlines 函数按换行符对其进行拆分。
contents= string(contents);
contents= splitlines(contents);
contents(10:14)用空格替换一些标点字符。
p = ["." "?" "!" "," ";" ":"];
contents= replace(contents,p," ");
contents(10:14)将 contents拆分为其元素包含单个单词的字符串数组。要完成此操作,需要将所有字符串元素合并成一个 1×1 字符串,然后在空白字符处进行拆分。
contents = join(contents);
contents= split(contents);删除少于五个字符的单词。
contents(strlength(contents)<5) = [];将 contents转换为分类数组,然后使用 wordcloud 进行绘图。此函数绘制 C 的唯一元素,大小与这些元素的频率计数对应。
C = categorical(contents);
figure
wordcloud(C);
title("Matlab Word Cloud")边栏推荐
猜你喜欢

Shell integrated application cases, archiving files, sending messages

Uninstall cuda11.1

Qt 学习(二) —— Qt Creator简单介绍

pillow的原因ImportError: cannot import name ‘PILLOW_VERSION‘ from ‘PIL‘,如何安装pillow<7.0.0

并发之线程状态转换

QT learning (II) -- a brief introduction to QT Creator

Reason for pilot importerror: cannot import name 'pilot_ Version 'from' PIL ', how to install pilot < 7.0.0

WGAN、WGAN-GP、BigGAN

Interview Essentials: shrimp skin server 15 consecutive questions

3D人脸重建:Joint 3D Face Reconstruction and Dense Alignment with position Map Regression Network
随机推荐
Uninstall cuda11.1
语音数据采集-实时语音数据可视化
文件上传漏洞绕过方法
Discussion on a problem
Snowflake vs. databricks who is better? The latest war report in 2022
Snowflake vs. Databricks谁更胜一筹?2022年最新战报
StyleGAN论文笔记+修改代码尝试3D点云生成
PCL各模块概述(1.6)
Food safety | the more you eat junk food, the more you want to eat it? Please keep this common food calorimeter
Anaconda安装(非常详细)
面试京东 T5,被按在地上摩擦,鬼知道我经历了什么?
Intermediate and advanced test questions ": what is the implementation principle of mvcc?
Mysql database experiment training 5, data query YGGL database query (detailed)
Xiandai 004
Matlab- draw superimposed ladder diagram and line diagram
Review of in vivo detection
3D restoration paper: shape painting using 3D generative advantageous networks and recurrent revolutionary networks
Shell流程控制(重点)、if 判断、case 语句、let用法、for 循环中有for (( 初始值;循环控制条件;变量变化 ))和for 变量 in 值 1 值 2 值 3… 、while 循环
Shell中的文本处理工具、cut [选项参数] filename 说明:默认分隔符是制表符、awk [选项参数] ‘/pattern1/{action1}filename 、awk 的内置变量
Pygame: alien invasion