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

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学苑整理并发出,如有侵权,请联系删除。

    推荐阅读
  • 孔子诞辰日(孔子的生日)

    以下内容希望对你有帮助!孔子诞辰日孔子诞辰,全称孔子诞辰纪念日,是纪念孔子诞辰的节日,为鲁襄公二十二年夏正八月二十七,即鲁襄公二十二年十月庚子日(周正)或西历9月28日。孔子是春秋时期的著名教育家,被尊为“至圣先师”,鲁襄公二十二年诞生于今山东曲阜。

  • 猪腰子的功效与作用(猪腰的功效与作用)

    强身补虚猪腰子中含有大量的蛋白质、脂肪以及维生素等物质,这些物质是人体能量的主要来源,可以帮助促进人体的细胞修复和代谢,具有一定强身补虚的作用,有利于人体健康。高胆固醇人群适量食用猪腰子中含有大量的蛋白质以及脂肪等营养物质,高胆固醇人群过量食用容易导致其体内的胆固醇含量上升,从而诱发或者加重其病情,对他们的健康造成威胁,所以高胆固醇患者是不建议过量食用猪腰子的。

  • 水原希子红毯礼服(秀恩爱亮瞎单身狗)

    水原希子红毯礼服GD和水原希子这对情侣从去年恋情曝光后,就有网友盘点她们近期的街拍造型,而这些情侣装虽然有点穿越,但是也是秀恩爱的证据!水原希子在2011年晒出来的一张照,身穿Playboy的Tee和权志龙去年的“冰桶挑战Look”登对上了,该T恤在几年前GD和水原希子传出热恋绯闻的时候就被视为是“热恋证据”,如今终于能见天日了。1月28日仁川机场中,GD穿了一件可抖骚的毛衣了~大大的狐狸头一眼定睛,你确定不是那神烦的“Doge”?

  • 饺子馅怎么调又多汁又好吃(过节调饺子馅牢记2放3不放)

    多种香料的香味,全部融入到食用油中以后,就能让饺子馅的口感更香。首先不能放大的是五香粉,因为五香粉中,掺杂了太多气味重的香料,这些香料很容易就会影响肉馅的鲜美口感。所以在调肉馅的时候,切记用料不能乱用,尤其是五香粉。然后先加入葱、姜水,记住要分几次去加入,这样才能使肉馅充分吸足水分。

  • 李娜恩 表艺珍(表艺珍接替李娜恩收视上升)

    结果剧集日前正式开播后,论话题度还是收视率都直线上升,成为成功化危机为转机的剧集之一。李娜恩因为卷入霸凌事件导致被剧组换角,拍好的片段全部被删除。《模范的士》于4月9日以10.7%的高收视率开播,之后每集的收视都不断上升,上星期播出第四集已经突破15.6%,最高收视更达到16.3%大受欢迎,临时加入剧组的表艺珍亦凭出色表现大受关注。

  • 生物进化最后一个方向(生物进化的背后)

    进化论的支持者赫胥黎在其“天演论”里又进一步发挥了“物竞天择,适者生存”这一思想。这种生存斗争包括同种生物个体和不同种个体之间的斗争,以及生物与自然条件斗争。进化论虽然受到很多质疑,但关于人类的起源问题,至今还没有一个更合适的学说能够替代“进化论”的学说。无论是“进化论”、“神创论”、“外星论”,都缺乏明确的证据。

  • 衍太太的性格特点 衍太太的性格特点及事件

    怂恿鲁迅看下流书籍。怂恿“我”去偷母亲的首饰,还散布谣言。作品介绍了鲁迅先生冲破封建束缚,为追求新知识,离家求学至出国留学的一段生活经历。

  • 什么是公元年份(了解一下常识)

    什么是公元年份公元即“公历纪元”,使用格里历,以传说中的耶稣出生之年为元年。历史由来“公元”产生于公元6世纪。公元532年,教会把狄奥克列颠纪年之前的284年作为公元元年,并将此纪年法在教会中使用。公元1582年罗马教皇制定格里历时继续采用了这种纪年法。

  • 银杏树扦插什么时间容易成活(银杏什么时候扦插成活率高)

    回答银杏树老枝扦插在3-4月容易成活,而嫩枝扦插在5月末至6月中旬容易成活。老枝扦插可选择1-2年生的健康枝条进行,截为15-20厘米的枝条,浸泡在生根溶液内1-2天,再扦插入土壤中,浇水养护待生根;新枝扦插可在其根部周围,选择尚未木质化的枝条,截长2厘米长,放入培育盆中直到剪口愈合即可移入苗床中。

  • 泸县踏青好去处 泸县游玩的地方

    泸县道林沟道林沟是人人称赞的“川南小九寨”,其湖水优美明净,湖畔绿树成荫,远远望去一片翠绿,是春日里踏青出游的首选目的地!迎着春日暖阳,来道林沟,观千亩茶园,看竹影婆娑,听山间鸟鸣,还有洁白的李花相伴,尽情感受春日的美好!踏青地点:泸县玉蟾山风景区最佳踏青期:3月至4月自驾路线:泸县城区--祥和路--建设街--泸县玉蟾山风景区周边观赏点:摩崖造像、流民图、金鳌峰、白龙塔等