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

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

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

分享兴趣,传播快乐,增长见闻,留下美好!将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学苑整理并发出,如有侵权,请联系删除。

    推荐阅读
  • 录屏软件怎么做到分屏(关于电脑屏幕那些事儿)

    ③按快捷键WindowsAltG打开录屏功能,WindowsAltR开始录制。02Windows分屏如果你想要在一个显示器上进行分屏,查看当前打开软件,可以使用快捷键实现。Windows录屏/分屏多个桌面,这个组合有没有惊艳到你呢?

  • 蟹爪兰最好的花期是什么时候(蟹爪兰步入盛花期)

    入冬以后,蟹爪兰逐渐开始步入盛花期。一少蟹爪兰进入盛花期,一少是指少搬动。二多多光照蟹爪兰在开花期间,应保证充足光照。三控控制浇水蟹爪兰在开花期间,正常浇水,盆土七八分干的时候浇即可。岂不知浇水多,蟹爪兰根部氧气供应不足,就会引起花苞、花朵脱落。控制温度温度的高低,直接会影响蟹爪兰花期的长短。蟹爪兰不喜欢大温差的环境,温度稳定温差小,更有利于延长花期。除此之外,蟹爪兰有花朵凋谢,要及时把残花掐掉。

  • wpsppt动画触发器怎么设置 wps演示动画设置里的触发方式

    wpsppt动画触发器设置方法如下:1、建立一个PPT模板,插入动画图片。

  • 北京四中数学特级教师(数学特级教师谷丹)

    数学特级教师谷丹认为,要想学好数学,那么就要把握好两个核心点,平时注重养成3个习惯。养成3个习惯:1、全面梳理知识点在谷丹看来,很多学生学习数学的方式是机械性质的,虽然具有一定的夯实基础的作用,但是这样的抄写复制方法,却不是高效率学习数学的方式。

  • 《暗黑破坏神3:夺魂之镰》2.1PTR猎魔人大箭塔各武器档位对比分析

    在这里LZ和大家一起讨论一下2.1大箭塔各武器、各档位的对比。由于2.1自射流LZ还没有开始尝试,所以本文讨论的都是关于不射流的,敬请包涵。重点提一下7档7速ED的极品灾虐,由于全程覆盖的标记特效,相同素质的7档灾虐妥妥超过六档冰弓,是名副其实的第一。6档冰弓紧随其后,排名第二。6档元素弓和6档灾虐屈居季军。

  • 生化危机3重制版角色有哪些 生化危机3重制版叫什么名字

    D小队被投入拉库恩市以营救市民,但超出预期的惨状让部队濒临毁灭,自身也负伤累累。为了执行任务并确保自身利益他不惜牺牲一切,态度冷漠。在洋馆事件后仍留在拉库恩市协助展开安布雷拉的相关调查。他的目标是与吉尔一同逃离拉库恩市。摩菲·希克所属安布雷拉私人部队U.B.C.S的A分队,前美国海军陆战队所属的优秀狙击手。在丧尸战中身负重伤。

  • 面南瓜和菜南瓜的区别(菜南瓜和面南瓜的区别)

    面南瓜和菜南瓜的区别南瓜:山东地区称作吊瓜,东北地区称作倭瓜。原产于南美洲,后传入我国。南瓜传入中国有多条路径,但以广东、福建、浙江为最先。到了清朝中后期,中国南边南瓜沿大运河向北移栽,尤其是山东,成了北方南瓜莳植重镇,人们开始意识到此瓜应自南来,“南瓜”之称开始盛行。面瓜就相当于甜瓜像水果可以生吃,但是南瓜属于蔬菜。

  • 什么叫好奇心(新知问答什么是好奇心)

    秀丽隐杆线虫他们发现,这种昆虫在搜索食物之前,会先密集的探索一小片区域,然后再进行更大范围的的搜索。探索的紧张性放电表现出高于直接决策的放电PCC与奖励和学习有着密切的相关,也就是说这项研究可能暗示好奇心与奖励和学习调节息息相关。而存在混淆的,孩子则无法判断。该结论支持了好奇心可能是为了解决不一致信息的假设。

  • 176小时救援被困3人全部获救(34夺命救援)

    12月1日,在河北邯郸市魏县境内漳河搜寻一名落水失联的渔民时,广平县蓝天救援队队员武海义等人所在船只发生侧翻,已上岸整理装备的临漳县蓝天救援队队员孙晓森,发现险情后再次返回救援时不慎落水,两人双双遇难。而仅在一周前的11月23日,邯郸市大名县蓝天救援队在搜寻同一落水渔民时,同样发生了救生艇侧翻,致1名队员死亡。8天内邯郸市3名蓝天救援队队员遇难,引起广泛关注和质疑。

  • 学习技术永远不到顶峰(技术依赖学不致用)

    社会经济发展状况似乎是造成“学习危机”的原因。北京师范大学学生姚佳曾到我国最不发达的地区参与过评估工作。不久前,刘雨菲成为一名志愿教师,在一所学校教英语。在不久前举办的2022全球智慧教育大会上,世界工程组织联合会前任主席、中国新一代人工智能发展战略研究院执行院长龚克指出,如今,数字化的教育必须突出“实践性”。名单公布之后,肖晓那颗担心自己被分流出去的心也终于放下了。肖晓所在班级是年级的重点班。