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

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

    推荐阅读
  • 2022年值得入手的手机有哪些款(2022年哪些手机不能买)

    组装机是指有专业技术的人自己组装起来的手机,为避免也是要到正规渠道购买。红米9A起售价现在是599,比其便宜100,联发科G25,附送充电器,其使用联发科芯片的机型多,不担心兼容问题。红米9A起售价799,比其多100,联发科G80处理器、1080P的屏幕分辨率、大功率的扬声器、还支持18W充电。保留了3.5毫米耳机孔,支持最高1T内存卡内存拓展,没有红外遥控,没有NFC。

  • 用什么东西能快速消除水垢(去除水垢不再难)

    倒掉山芋,就能发现水垢会逐渐脱落!这时,千万不能擦洗内壁,不然就会失去除垢作用。煮沸后,放置半小时左右,再用清水洗刷。

  • 南瓜饼的做法步骤(南瓜饼的做法)

    跟着小编一起来看一看吧!南瓜饼的做法步骤南瓜、牛奶、豆沙、糯米粉、干果。将南瓜去皮,切成块状,煮熟并捣成泥,注意不要放太多的水。加入糯米粉和少量牛奶,和成团状,揉得干一点比较好,面团里也可加少量食用油,会使成品外观比较有光泽。用油煎,南瓜饼就完成了。

  • 成都稻田公园门票(红星带你耍成都)

    位于崇州市非遗竹编小镇道明镇的无根山竹艺公园,经过近两年的精心打造,于今年10月1日正式开园试运营。它全程约1公里,是西南地区第一条大坡度齿轨登山观光专线。最终,整个竹艺公园项目设计将依据现状基底条件及功能需求,构建起“一心·四区·一集群”的总体格局。全国党媒信息公共平台提供信息发布传播服务。

  • 欧莱雅性价比高的面霜(欧莱雅三生花佰草集的4款面霜)

    面霜的选择可不仅仅只是看适不适合自己的肤质,更要根据不同的皮肤状态和时间段进行调整,面霜也分为日霜和晚霜。日霜,就是白天使用的面霜。是一款主打抗初老和保湿的面霜,但是后续添加了物理防晒,所以我认为比较适合当做日霜。对于平滑皮肤镇静维稳有一定的帮助,个人觉得他胜在质地比较轻盈,涂上脸之后没有负担,保湿度也不错,也是属于一款基础性的保湿面霜没有太多功效性的成分,当做日霜使用足够了。

  • 球球大作战大逃杀从哪玩啊(球球大作战大逃杀攻略)

    不像自由模式会一不小心吃到队友。所以一定要避免被吃掉。和其他模式一样,同样有刺球,所以开局要尽快吃刺球发育,刺球有大有小,前期发育很简单,只要你不被吃。笑到最后的人就是最后的冠军了。

  • 一剑霜寒十四州是哪十四州 一剑霜寒十四州的十四州有多大

    从北往南,当时两浙共有13个州:润州、常州、苏州、湖州、杭州、婺州台州、温州、衢州、越州、明州、睦州、括州。

  • 蒙阴县关于抓紧接种新冠疫苗第一针的通告

    蒙阴县关于抓紧接种新冠病毒疫苗第一剂次的通告广大市民朋友们:根据中央和省市新冠病毒疫苗接种工作总体部署,截止7月25日,原则上集中组织辖区内18周岁以上人群第一剂次接种,凡年满18周岁及以上且无接种禁忌症的人员均须接种新冠疫苗,为了您和家人的健康,请未开展第一剂次接种的,25日前务必到辖区接种点进行接种。附件:蒙阴县新冠疫苗接种点汇总表县委新冠肺炎疫情处置工作领导小组(指挥部)办公室2021年7月19日

  • abcc式的词语有哪些(含abcc式的词语盘点)

    abcc式的词语有哪些?以下内容大家不妨参考一二希望能帮到您!abcc式的词语有哪些abcc式的词语有:天网恢恢、大名鼎鼎、想入非非、怒气冲冲、议论纷纷、生机勃勃、白雪皑皑、得意洋洋、气喘吁吁。文质彬彬、可怜巴巴、人才济济、波光粼粼、言之凿凿、目光炯炯、白发苍苍、饥肠辘辘、含情脉脉、热气腾腾、风尘仆仆、兴致勃勃、行色匆匆、微波粼粼、野心勃勃等等

  • 我的世界最难版本的末影龙(关于末影龙的40个趣闻)

    因为末影龙会将其接触到的所有方块破坏掉。如果末影龙死亡后箭矢还有剩余,则会向四面八方散去。