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

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

    推荐阅读
  • 初中科学知识点大全总结(40道小升初自然科学知识题)

    40道小升初自然科学知识题,接下来我们就来聊聊关于初中科学知识点大全总结?答;钨第7题问:对病毒的治疗,目前世界上最好的方法是那种?答:复果类第12题问:1869年3月,哪位科学家正式公布了元素周期律?答:门捷列夫第13题问:极地越野车是模仿什么动物行走而设计制造的?答:蓝色第32题问:目前,阑尾在人体内的作用被认为是什么?答:免疫系统的一部分第33题问:北极星处于天空中的什么星座?

  • 心锁生锈怎么办(锁心坏了怎么撬开)

    生活中难免会遇到锁芯坏了的情况,自己又不知道怎么来处理会比较好,那么锁心坏了怎么撬开呢?PChouse就带大家来了解一下吧。

  • 开合跳全套减肥动作(一个全身燃脂的动作)

    开合跳这个动作,热身效果非常强,不仅可以快速提高个人的心率,加快身体升温,而且还可以帮助我们快速进入到运动的状态,以及预防运动过程中受伤。开合跳作为一个超燃脂的动作,也是深受减肥人士的热爱。很多人一开始跳开合跳,坚持一个礼拜后就会很容易上瘾。开合跳是有氧运动以及无氧运动的结合体,对于个人体能以及体质的提高都有很大的提升作用。开合跳能有效减少了肌肉的流失,提高身体的代谢效率,让你收获更好的身材线条。

  • 周美娜梦瑶志伟是哪部电视剧(想知道的快来这里了解下)

    周美娜梦瑶志伟是哪部电视剧周美娜梦瑶志伟是《谎言背后》里的人物。《谎言背后》由凤仪传媒集团出品打造,张族权执导,牛飘、侯天来、杨子仪、汪洋等主演。2013年12月12日天津都市频道首播,2014年4月17日浙江卫视(上午)及4月23日湖北卫视(上午)上星。

  • 霸气的游戏名字女(萝莉高冷个性游戏网名)

    霸气的游戏名字女?下面希望有你要的答案,我们一起来看看吧!霸气的游戏名字女撩人妖精姐的拽^你挡不住请注意你的素质别碰我的人生嘴唇爱上了香烟时代佳人一身傲骨傻B中的战斗机。

  • 推荐50本熬夜看完的小说(小说推荐)

    推荐50本熬夜看完的小说《牧神记》宅猪目前巅峰作,也是19年爆款玄幻作品。主要讲述灵气复苏背景下,主角依靠沾沾卡沾一切的故事。主角依靠消耗寿命提升武功的金手指,在异界为所欲为的故事。《斗罗大陆》全网第一IP,《斗罗大陆》系列至今十多年了,但是依旧驰骋网文界。三少无愧“网文之王”的称号。《斗罗大陆》是部分年轻书友的入坑作,也是一本经典的玄幻小说。主角得到惩恶令,在这个世界,代天惩恶!

  • 特别出演什么意思(什么是特别出演)

    什么是特别出演特别出演,指在电影、电视连续剧里,邀请有名、同层次的演员或拜托比主演层次更高的演员助演或配角特别出演就是在电视剧或者电影中一些很重要的角色,戏份不多但是需要超厉害的大牌演员来演因为不是主角,所以不能把。

  • 三年级数学下册商中间是0的除法(三年级数学下册商中间或末尾有0的除法知识点及练习)

    《商中间或末尾有0的除法》是三年级数学下册的重要知识点,考试一定会考!商中间或末尾有0的除法知识点一:商中间或末尾有0的除法(一)1、只要平均分,就用除法计算;一个物体也没有,用0表示;在运算时,0还有占位的作用。0除以任何数都得0.()720÷4的商是三位数。李泽5分钟打了650个字,陈东8分钟写了256个字。李泽平均每分钟打字比陈东平均每分钟写字多多少个?

  • 枕芯发黄怎么洗 枕芯发黄简单有效的清洗方法

    将枕芯浸泡在米水里约20分钟,然后定期清洗。

  • 不吃早餐的严重后果你知道吗(不吃早餐的危害)

    美国哈佛大学的研究还证实,这种做法会使患心脏病危险增加27%。4加速衰老不吃早餐,人体只能动用体内储存的糖原和蛋白质,久而久之会导致皮肤干燥、起皱和贫血,加速衰老。②吃一定量的肉类、鸡蛋等动物性食品,以补充蛋白质及微量元素。③喝一定量牛奶或豆浆,鸡蛋、牛奶、肉等食物主要提供蛋白质,可数小时内持续释放能量。