肥宅钓鱼网
当前位置: 首页 钓鱼百科

matlab仿真建模实例(八悦文摘九:Matlab二维)

时间:2023-07-14 作者: 小编 阅读量: 1 栏目名: 钓鱼百科

分享兴趣,传播快乐,增长见闻,留下美好!将sz定义为指定气泡大小的向量。例如,将patients.xls以表tbl形式读取。通过将tbl作为第一个参数传递给bubblechart函数,后跟变量名称,绘制Systolic、Diastolic和Weight变量。默认情况下,轴标签与变量名称匹配。例如,创建一个包含四个随机数变量的表,并绘制X和Y变量。气泡大小根据Sz变量而改变,颜色根据Colors变量而改变。histogram2函数自动选择合适的bin数量,以便涵盖x和y中的值范围并显示基本分布的形状。

分享兴趣,传播快乐,

增长见闻,留下美好!

亲爱的您,这里LearningYard学苑。

今天小编为大家带来的是《Matlab二维、三维绘图(4)》

大约需要您五分钟的时间。

欢迎您的访问。

Share interest,

spread happiness,

Increase knowledge and leave good news!

Dear you, this is LearningYard Academy.

Today, the editor brings you "Matlab 2D and 3D plot (4)"

It will take you about five minutes.

Welcome your visit.

1

绘制随机气泡并指定颜色

将气泡坐标定义为向量 x 和 y。将 sz 定义为指定气泡大小的向量。然后创建一个由 x 和 y 定义的气泡图,并将颜色指定为红色。默认情况下,气泡是部分透明的。

Define bubble coordinates as vectors x and y. Define sz as a vector specifying the size of the bubble. Then create a bubble chart defined by x and y and assign the color red. By default, bubbles are partially transparent.

输入:

x = 1:20;

y = rand(1,20);

sz = rand(1,20);

bubblechart(x,y,sz,'red');

可以得到以下图案。

Enter:

x = 1:20;

y = rand(1,20);

sz = rand(1,20);

bubblechart(x,y,sz,'red');

The following patterns can be obtained.

2

绘制随机气泡并指定颜色

对于自定义颜色,可以指定 RGB 三元组或十六进制颜色代码。例如,十六进制颜色代码 '#7031BB' 指定紫色。

For custom colors, you can specify an RGB triplet or a hexadecimal color code. For example, the hexadecimal color code '#7031BB' specifies purple.

输入:

bubblechart(x,y,sz,'#7031BB');

可以得到以下图像。

Enter:

bubblechart(x,y,sz,'#7031BB');

The following images can be obtained.

3

绘制表中的数据

绘制表中数据的一种便捷方法是将表传递给 bubblechart 函数,并指定要绘制的变量。例如,将 patients.xls 以表 tbl 形式读取。通过将 tbl 作为第一个参数传递给 bubblechart 函数,后跟变量名称,绘制 Systolic、Diastolic 和 Weight 变量。默认情况下,轴标签与变量名称匹配。

A convenient way to plot the data in a table is to pass the table to the bubblechart function and specify the variables to plot. For example, read patients.xls as table tbl. Plot the Systolic, Diastolic, and Weight variables by passing tbl as the first argument to the bubblechart function, followed by the variable names. By default, the axis labels match the variable names.

输入:

tbl = readtable('patients.xls');

bubblechart(tbl,'Systolic','Diastolic','Weight');

可以得到如下图像。

Enter:

tbl = readtable('patients.xls');

bubblechart(tbl,'Systolic','Diastolic','Weight');

The following image can be obtained.

4

使用自定义颜色绘制表数据

调用 bubblechart 时,可以通过指定 cvar 参数绘制表中数据并自定义颜色。

例如,创建一个包含四个随机数变量的表,并绘制 X 和 Y 变量。气泡大小根据 Sz 变量而改变,颜色根据 Colors 变量而改变。

When calling bubblechart, you can draw the data in the table and customize the color by specifying the cvar parameter.

For example, create a table with four random number variables and plot the X and Y variables. The bubble size changes according to the Sz variable, and the color changes according to the Colors variable.

输入:

tbl = table(randn(15,1)-10,randn(15,1) 10,rand(15,1),rand(15,1), ...

'VariableNames',{'X','Y','Sz','Colors'});

bubblechart(tbl,'X','Y','Sz','Colors');

可以得到以下图像。

Enter:

tbl = table(randn(15,1)-10,randn(15,1) 10,rand(15,1),rand(15,1), ...

'VariableNames',{'X','Y','Sz','Colors'});

bubblechart(tbl,'X','Y','Sz','Colors');

The following images can be obtained.

5

向量的直方图

生成 10000 个随机数对组并创建一个二元直方图。histogram2 函数自动选择合适的 bin 数量,以便涵盖 x 和 y 中的值范围并显示基本分布的形状。

Generate 10000 random number pairs and create a binary histogram. The histogram2 function automatically chooses an appropriate number of bins to cover the range of values in x and y and to show the shape of the underlying distribution.

输入:

x = randn(10000,1);

y = randn(10000,1);

h = histogram2(x,y)

可以得到如下图像。

Enter:

x = randn(10000,1);

y = randn(10000,1);

h = histogram2(x,y)

The following image can be obtained.

6

指定直方图的 bin 数量

为划分入 25 个等间距 bin 的 1,000 个随机数对组绘制一个二元直方图,其中每个维度使用 5 个 bin。

Plots a bivariate histogram of 1,000 pairs of random numbers divided into 25 equally spaced bins, using 5 bins for each dimension.

输入:

x = randn(1000,1);

y = randn(1000,1);

nbins = 5;

h = histogram2(x,y,nbins)

可以得到以下图像。

Enter:

x = randn(1000,1);

y = randn(1000,1);

nbins = 5;

h = histogram2(x,y,nbins)

The following images can be obtained.

7

按高度对直方图条形着色

使用 1000 个正态分布的随机数创建一个二元直方图,其中每个维度有 12 个 bin。将 FaceColor 指定为 'flat' 以按高度对直方图条形着色。

Create a bivariate histogram using 1000 normally distributed random numbers with 12 bins in each dimension. Specify FaceColor as 'flat' to color the histogram bars by height.

输入:

h = histogram2(randn(1000,1),

randn(1000,1),[12 12],'FaceColor','flat');

colorbar

可以得到如下图像。

Enter:

h = histogram2(randn(1000,1),

randn(1000,1),[12 12],'FaceColor','flat');

colorbar

The following image can be obtained.

8

创建三维饼图

创建向量 x 的三维饼图。

Create a 3D pie chart of vector x.

输入:

x = [1,3,0.5,2.5,2];

figure

pie3(x)

可以得到以下图像。

Enter:

x = [1,3,0.5,2.5,2];

figure

pie3(x)

The following images can be obtained.

9

创建条形图

输入:

y = [75 91 105 123.5 131 150 179 203 226 249 281.5];

bar(y)

可以得到如下图像。

Enter:

y = [75 91 105 123.5 131 150 179 203 226 249 281.5];

bar(y)

The following image can be obtained.

10

显示条形组

显示四个条形组,每一组包含三个条形。

Displays four bar groups, each containing three bars.

输入:

y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];

bar(y)

可以得到以下图像。

Enter:

y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];

bar(y)

The following images can be obtained.

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天,

祝您今天过得开心快乐!

That's it for today's sharing.

If you have a unique idea for today's article,Welcome to leave us a message.

Let's meet tomorrow.

I wish you a great day today!

参考资料:谷歌翻译、百度

本文由Learning Yard学苑整理并发出,如有侵权,请联系删除。

    推荐阅读
  • 八个字句子简单晚安(八个字句子简单晚安有什么)

    以下内容大家不妨参考一二希望能帮到您!八个字句子简单晚安各自努力,顶峰相见。鲜衣怒马,此间少年。白白胖胖,充满希望。永以为好,你最值得。生而热忱,终也欢洽。但行好事,莫问前程。望云知变,闻风而动。绿水无忧,因风皱面。不之所起,一往情深。都会有的,都会好的。始于颜值,终于习惯。林无静树,川无停流。

  • 常见词语词义(常用词语经常用)

    '"四体指双臂、双腿。胡,中国古代对西、北部少数民族的称呼。指毁坏皇家宗庙、陵寝、宫殿的行为。谋叛是指叛逃到其它敌对国家。偷盗皇帝祭祀的器具和皇帝的日常用品,伪造御用药品以误犯食禁。指殴打、杀死长官,丈夫死后不举哀并作乐改嫁等。指与祖父、父亲的妾通奸。

  • 潮图壁纸长图(文字潮图壁纸系列)

    文字潮图壁纸系列,。

  • 微波炉烘干大枣方法(微波炉烘大枣具体做法)

    微波炉烘干大枣方法微波加热箱内磁场分布并不均匀,为了保证物料均匀受热,枣子的放置就必须有讲究。我们把枣子放在微波机加热箱内的托盘上,加热时枣子随托盘匀速转动,使物料均匀接受箱体内的微波辐射,由箱体外部的智能温控调湿系统来及时控制箱内物料的温度和湿度。注意事项:微波照射时间控制在190s内,枣子表面温度控制在70℃以下,枣子烘干品质最佳。

  • 咸蛋黄茄子(怎么做咸蛋黄茄子)

    以下内容大家不妨参考一二希望能帮到您!咸蛋黄茄子主料:茄子500克。调料:植物油1000克,精盐2克,味精3克,大蒜子10克,葱10克,香油5克,湿淀粉5克,鲜汤20克。茄子去皮切成4厘米长,1厘米见方的条;盐蛋黄用刀压扁,改成1厘米见方的块;尖椒切圈;大蒜子切末;葱切段。锅置旺火上,入油烧至六成热,下入茄子炸至金黄色,倒入漏勺沥油;另取部分植物油将盐蛋黄略炸捞出。

  • 腻子粉自动粉料需要多大气泵(装修气泵有什么用)

    最小的一般2.5或3P的就可以用但是个人建议用大一点的,3P的气泵,工作量和工作强度都很大,今天小编就来说说关于腻子粉自动粉料需要多大气泵?腻子粉自动粉料需要多大气泵最小的一般2.5或3P的就可以用。气泵是从一个封闭空间排除空气或从封闭空间添加空气的一种装置。装修气泵可以打气钉和,喷漆用。还能撤装螺丝,气圧越大劲就越大价格就越高。就是空气压缩机,有大有小的。不过,做活的师傅们都有,不用买的。

  • 离婚后户口迁移手续流程多久(离婚后如何办理户口迁移手续)

    离婚后的户口迁移,妇女往往是迁出的一方,这并不妨碍户口迁移程序的进行。关于离婚户口迁移,我国《户口登记条例》明确规定:第十条第一款规定,公民迁出户口管辖区的,应当在迁出前向户口登记机关申报迁出登记,领取迁出证明,注销户口。因此,法律还规定了不同地方的户口迁移程序。离婚诉讼户口迁移手续。

  • cfa考试成绩查看(CFA考试成绩何时公布)

    CFA考试成绩何时公布上海cfa考试成绩何时公布?2022年2月CFA考试窗口已经关闭,考生在完成考试之后,比较关心的就是成绩的问题,下面就来一起看一下,上海cfa考试成绩何时公布?本文还附有CFA考试成绩的查询方式说明根。

  • 声律启蒙作者是哪个朝代(声律启蒙作者的介绍)

    声律启蒙作者是哪个朝代?跟着小编一起来看一看吧!车万育bai,字双亭,号鹤田,湖南邵阳人。康熙甲辰du进士,官至兵科给zhi事中。康熙二年,与兄万备同举湖广乡试,1664年成进士,选庶吉士。性刚直,直声震天下,至性纯笃,学问赅博。善书法,所藏明代墨迹最富,有萤照堂明代法书石刻十卷。《声律启蒙》被称作最美音韵的国学经典。是清朝康熙年间进士、清朝学者车万育所作,在清朝是家喻户晓的儿童启蒙读物。

  • 两位驴友登山被困悬崖可长点心吧(暴雨中徒步探险被困浙东大峡谷)

    市局指挥中心接报后,立即将情况通报浙江省公安厅指挥中心核查。当晚8时许,浙江省宁海县警方从现场反馈,团中有8人先期已脱困,被困游客实际为25人。经过警方4个多小时的搜索,被困人员位置基本确定。当晚11时10分,救援现场确认被困人员情况稳定。24日凌晨5点30分,被困人员全部脱困,第一批15人安全抵达张辽村;上午9时许,所有被困人员获救,无一受伤。