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

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

    推荐阅读
  • 暗黑破坏神2战网bug(暗黑破坏神2新手战网使用指南)

    启动d2loader的快捷键后暗黑2启动快捷键先点battle.net进入战网战网登陆界面请再次确定你是点的battle.net即下图的地方进入才是正确的!(千万不要从最后一个"其他多人游戏"里进入,那里的battle.net是错误的!!

  • 自制酸牛奶的做法(自制酸牛奶怎么做)

    自制酸牛奶的做法?食材:800ml-1000ml纯牛奶、1g酸奶发酵剂牛奶及菌粉要提前从冰箱取出恢复至室温,下面我们就来聊聊关于自制酸牛奶的做法?自制酸牛奶的做法食材:800ml-1000ml纯牛奶、1g酸奶发酵剂。酸奶机内胆开水充分冲烫消毒。加入1小包酸奶菌粉,轻轻搅匀。放入酸奶机中恒温发酵6-10小时,待观察到牛奶凝固即可。做好的酸奶可立即食用,也可放入冰箱冷藏数小时,风味更佳!食用时也可根据个人喜好加入白砂糖或其他果酱调味。

  • word中怎么没有删除背景的选项(word找不到删除背景这一项)

    MicrosoftOfficeWord是微软公司的一个文字处理器应用程序。它最初是由RichardBrodie为了运行DOS的IBM计算机而在1983年编写的。随后的版本可运行于AppleMacintosh、SCOUNIX和MicrosoftWindows,并成为了MicrosoftOffice的一部分。

  • 充电线3a5a哪个充电快(3a充电线与5a充电线哪个快)

    5A比3A电流大,所以同样的时间内5A的充电快。数据线是用来连接移动设备和电脑,来达到数据传递或通信目的的线。COM接口也叫串口,是接在台式电脑后面的,正在被淘汰。USB接口是主流,优点是方便快速稳定,支持所有型号的电脑;缺点是带IC的价格稍高,另外部分数据线不支持刷机功能。也没有什么特别好的方法,毕竟手机型号太多了。

  • 叠字组词(叠字组词有哪些)

    叠字组词三叠系造句:认为该区的铁矿床是以矿浆充填贯入成因为主,近矿闪长岩的钠化作用及三叠系地层不能为成矿提供主要的物质来源,铁质主要来自深部上地幔。症状是突然腹痛、呕吐、大便带血等。在这个纪中,地质构造变化比较小,岩石多为砂岩、石灰岩等。动物多为头足类、甲壳类、鱼类、两栖类、爬行动物。植物主要是苏铁、松柏、银杏、木贼和蕨类。

  • 泰国最大的岛屿(普吉岛相关介绍)

    接下来我们就一起去了解一下吧!普吉岛,位于印度洋安达曼海东南部,是泰国境内唯一受封为省级地位的岛屿,岛上环境纯净,是一座著名的度假岛。普吉岛面积576平方公里,人口175万,属于热带季风气候。普吉岛主要农产品有橡胶、椰子、腰果和菠萝,此外在普吉岛的东面和南岸有养虾场和人工珍珠养殖场,但旅游业仍是普吉岛的第一收入来源。普吉岛与泰国南部安达曼海岸由桥梁相连。

  • 一年级数学下册认识图形易错题(一年级数学上册易错题型5)

    一年级数学下册认识图形易错题?以下内容希望对你有帮助!长方体:有6个平平的面。平放在桌子上能滚动,立在桌子上不能滚动。

  • 基本的净水方法有哪些 净水的主要方法

    从经济角度讲,蒸馏制水存在着耗水量大、用电成本高等弊病,如果是偏远地区,运输也会是一个麻烦,尤其是玻璃和石英蒸馏水器。

  • 王者荣耀如何越塔不挨打(越塔的4个技巧)

    王者荣耀如何越塔不挨打输出位绝对不能先抗塔,防御塔的第一攻击目标是最近单位或者是打到敌方英雄的那个人会被吸引火力。那么这个时候既然作出了要越塔的打算就不能着急,一定要让坦克先行吸引火力,这样脆皮既能打伤害又不用怕被反杀。也可以使用手长的英雄先行消耗,在最后直接进去收割即可,这样也减少防御塔对本身造成的伤害,也提高了自己的生存能力。

  • 怎么在手机上交电费(如何用手机交电费)

    以下内容希望对你有帮助!怎么在手机上交电费微信缴费,打开微信,在“我”里面找到“支付”,打开后点击“生活缴费”,然后选择“电费”,选择缴费单位,输入缴费编号,勾选协议后点击下一步,完成操作后即可成功缴费。