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

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

    推荐阅读
  • 乒乓球拍新手推荐(百元级乒乓球拍)

    斯帝卡也是中国国家队和瑞典国家队官方赞助商,刘国梁、丁宁等选手曾使用过斯帝卡球拍。需要注意的是,斯帝卡的球拍由于其较高的知名度,市场上有许多以假乱真的假货和山寨货,所以需要认准其官方的产品防伪码,谨防假冒。截止目前为200多名世界顶级运动员提供过服务,如孔令辉、张继科、马龙等。03斯帝卡|3星PURE幻彩初阶选手适用78.00这款3星PURE幻彩系列是较为出色的入门拍。

  • 经常穿没洗的新衣服有毒吗(新衣服为何一定要洗后再穿)

    您有没有想过,我们日常购买的新衣服可能并不那么“干净”?甲醛是一种无色,但具有刺激性的气体。甲醛是有害的,可对人体呼吸道造成刺激,使敏感接触者出现流泪、干呕等不适症状,还可对人体的皮肤粘膜造成刺激,使长期接触者出现皮炎、瘙痒、荨麻疹等过敏症状。对于儿童服装及易过敏人群来说,更是建议多次清洗,尽量彻底洗净。此外,晾晒时为防止一些彩色衣物出现变色、褪色,也可以将衣服进行反晒。

  • 电话卡暂停服务怎么回事 新买的电话卡暂停服务怎么回事

    2、在加油站或者加气站这样的地方一定要避免使用手机,因为手机发出的电磁波有可能引起静电,继而引发火灾。

  • 山南车船税缴纳指南 山东省车船税税率表

    本文为您介绍了山南车船税缴纳对象、车船税缴纳方法、车船税缴纳地点等相关信息,希望对您有帮助。其中,所有人是指在我国境内拥有车船的单位和个人;管理人是指对车船具有管理使用权,但不具有所有权的单位。

  • 玻璃静电贴总掉怎么办(静电贴不粘了的处理方法)

    玻璃静电贴总掉怎么办更换新的。若静电贴和玻璃或贴膜处产生粘连,可先用喷壶喷水,待标签湿润后用指甲把标签纸搞破并擦干水,最后用沥青清洗剂喷涂该处,约3分钟后静电贴和玻璃处会出现局部分离,撕开一点后再喷沥青清洗剂,这时静电贴软化,很容易就能把静电贴去掉并不伤害贴膜。把贴静电贴处的玻璃和塑料纸上的灰尘都清干净,重新贴之前一定要包装玻璃表面要干净,不要有油污或者其他的脏东西,以免贴补不牢。

  • 即将上市的新款凯美瑞(凯美瑞最新谍照曝光)

    距离凯美瑞换代车型国内上市还不到两年的时间,丰田汽车又将推出第八代凯美瑞车型。2015年凯美瑞销量为128046辆,同比增长32%;今年1-9月,累计销量75821辆,同比下降21.5%。近日,网上车市经海外媒体获得一组全新凯美瑞的伪装图,一些细节透露该车的性能的不同之处。所以该款新车谍照可能是TRD部门参与的性能版凯美瑞,有四孔排气管也就不奇怪了。新车将于2017年发布,预计2018年中国国内上市。

  • 重庆园博园游船多少钱? 重庆园博园船票多少钱

    重庆园博园游船多少钱?图源:摄图网_500927741重庆园博园园区占地面积3300亩,拥有4大功能区、5大特色建筑、127个城市展园、660余种共1200余万株植物,是一座集自然景观与人文景观于一身的超大型城市主题公园。重庆园博园从2021年10月1日起面向社会免费开放。为确保“安全有保障,品质不下降”,园区实行“免费不免票”,游客需提前分时段进行实名预约,预约成功后凭免费入园码、身份证、健康码入园游玩。

  • 2022海口江东新区言艺术馆需要门票吗

    海口江东新区言•艺术馆开放中,想要前往的需要提前进行预约,可以通过万华海南公众号预约。

  • 降温的方法(降温有什么方法)

    接下来我们就一起去研究一下吧!降温的方法多喝白开水,热水,静脉补充体液;温水擦身,擦拭的重点部位在皮肤皱褶的地方,例如颈部、腋下、肘部、腹股沟等;酒精擦拭,反复擦洗腋窝,腹股沟区,肘部,颈胸,后背及手足心等血管丰富的区域,通过蒸发降温;冰敷,以冰块或冰水作成冰帽,冰袋,冰枕等冷敷头部及腋下腹股沟等处,重点降低颅脑部温度,减少代谢及耗氧,保护大脑,以减少并发症和后遗症。