百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

Matlab二维绘图 matlab二维绘图的基本步骤

bigegpt 2024-10-28 12:47 3 浏览

Matlab




分享兴趣,传播快乐,增长见闻,留下美好。

亲爱的您,

这里是LearingYard学苑!

今天小编为大家带来matlab二维绘图

欢迎您的用心访问!

本期推文阅读时长大约5分钟,请您耐心阅读。


Share interest, spread happiness, increase knowledge, and leave beautiful.

Dear you,

This is the LearingYard Academy!

Today, the editor brings you matlab two-dimensional drawing

Welcome your visit!

This tweet usually takes about 5 minutes to read, please read it patiently.



#1 本期主题介绍

The topic of this issue


如果您了解过Matlab,

您肯定知道Matlab不只是计算!

Matlab还有一个强大的绘图功能!

本期话题将对matlab的二维图进行介绍。

请感兴趣的朋友和小编开启

学习Matlab的二维绘图之旅吧!


If you know Matlab,

You must know that Matlab is more than just computing!

Matlab also has a powerful drawing function!

The topic of this issue will introduce the two-dimensional map of matlab.

Please open it with interested friends and editors

Learn the journey of two-dimensional drawing in Matlab!


#2 Matlab二维绘图

Matlab two-dimensional drawing


1.绘制二维曲线

Draw a two-dimensional curve


plot函数的基本调用格式为:plot(x,y)

其中x和y为长度相同的向量,分别用于存储x坐标和y坐标数据;当x是实向量时,plot(x)以该向量元素的下标为横坐标,元素值为纵坐标画出一条折线图,当x为矩阵时,plot(x)以列为向量画出几条折线(矩阵列数);当x,y是同维矩阵时,则以x,y对应列元素为横、纵坐标分别绘制曲线,曲线条数等于矩阵的列数。

The basic calling format of the plot function is: plot(x,y)

Where x and y are vectors of the same length, which are used to store x coordinate and y coordinate data respectively; when x is a real vector, plot(x) uses the subscript of the vector element as the abscissa, and the element value is the ordinate to draw A polyline graph, when x is a matrix, plot(x) draws several polylines (the number of matrix columns) with columns as vectors; when x and y are matrixes of the same dimension, the corresponding column elements of x and y are horizontal and Draw curves on the ordinate, and the number of curves is equal to the number of columns in the matrix


#3 Matlab 二维绘图实际操作

Matlab two-dimensional drawing actual operation


1.plot绘单条曲线图

plot draw a single curve graph

x=0:0.01*pi:2*pi;

y=sin(x);

plot(x,y)


2.plot绘制多条曲线图

plot plots multiple curves


格式为:plot(x,y1,x2,y2,......,xn,yn)

The format is: plot(x,y1,x2,y2,......,xn,yn)

以向量对的形式绘制曲线。

Draw curves in the form of vector pairs.

x=0:0.01*pi:2*pi;

y1=sin(x);

y2=sin(x-0.25*pi);

y3=sin(x-0.5*pi);

plot(x,y1,x,y2,x,y3)

plot(x,y1,'-.b',x,y2,'--r',x,y3,'-.gh')

%b代表的是蓝色,r为红色,gh为绿色

%b represents blue, r is red, gh is green


3.hold on 与 hold off的应用

Application of hold on and hold off


如果绘制一个曲线后,想要保持当前曲线不变,在当前曲线基础上绘制新的曲线,这时我们可以采用”hold on”,关闭时可以用”hold off"。

If you want to keep the current curve unchanged after drawing a curve, and draw a new curve based on the current curve, we can use "hold on" at this time, and use "hold off" when closing.

x=0:0.1:1;

y=x;

plot(x,y)

hold on

x=1:0.1:2;

y=0.5*x.^4+0.5;

plot(x,y)

hold on

x=2:0.1:5;

y=-x.^2+9*x-5.5;

plot(x,y)

hold off


4.绘制特殊的二维曲线,比如只想要描述点,而不想要线

Draw a special two-dimensional curve, such as only wanting to describe points, but not lines


x=0:pi/15:4*pi;

y=exp(2*cos(x));

plot(x,y,'r+')


5.绘制对数曲线

Draw a logarithmic curve


x=linspace(1,100,100);

y=exp(x);

loglog(x,y)

%这样就绘制了双对数曲线

%This draws a double logarithmic curve

x=linspace(1,100,100);

y=exp(x);

semilogy(x,y)

%Y为对数坐标轴

%Y is the logarithmic axis

x=linspace(1,100,100);

y=exp(x);

semilogx(x,y)

%x为对数坐标轴

%x is the logarithmic axis




6.fplot函数的应用

%flot函数的基本用法:fplot(f,lims,参数)


f代表一个函数,通常采用函数句柄的形式。lims为x轴的取值范围,默认值为[-5,5]。参数与plot函数相同。

Application of fplot function

The basic usage of %flot function: fplot(f, lims, parameter)

f represents a function, usually in the form of a function handle. lims is the value range of the x-axis, and the default value is [-5, 5]. The parameters are the same as the plot function.

xt = @(t) cos(3*t);

yt = @(t) sin(2*t);

fplot(xt,yt)


%fplot双输入函数的基本用法:fplot(funx,funy,tlims,参数)

funx、funy代表函数,通常采用函数句柄的形式,tlims为参数函数funx和funy得到自变量取值范围。

fplot(@(t) t.*sin(t), @(t) t.*cos(t))


The basic usage of %fplot dual input function: fplot(funx, funy, tlims, parameter)

funx and funy represent functions, usually in the form of a function handle, tlims is the parameter function funx and funy to get the value range of the independent variable.

fplot(@(t) t.*sin(t), @(t) t.*cos(t))


7.polarplot函数的应用

Application of .polarplot function

t=0:0.1*pi:4*pi;

a=abs(sin(2*t).*cos(2*t));

polarplot(t,a,'-b+')


8.绘制图形的辅助操作

%给图形添加标注

%title (图形标题)

title('图形标题','Color,'r','FontSize',24)

%xlable(x轴说明)

%ylable(y轴说明)

%text(x,y,图形说明)

%legend(图例)

x=linspace(0,2*pi,100);

y1=sin(x);

y2=sin(2*x);

plot(x,sin(x),x,sin(2*x))

legend('sin(x)','sin(3x)','sin(2x)')

9.坐标轴

Coordinate axis control控制

%axis[xmin,xmax,ymin,ymax,zmin,zmax]

%axis equal:纵横坐标轴次采用等长刻度

%axis square:产生正方形坐标系(默认为矩形)

%axis auto:使用默认设置

%axis off:不显示坐标轴

%axis on :显示坐标轴

%给坐标轴加网格

%grid on

%grid off

%grid

%给坐标系加边框

%box on

%bix off

%box

%图形保存

%hold on

%hold off

%hold

x=linspace(0,2*pi,100);

t=linspace(0,2*pi,100);

x=sin(t);

y=cos(t);

plot(x,y,'b')

hold on;

plot(2*x,2*y,'r+');

grid on

axis([-2.2,2.2,-2.2,2.2])

axis equal


今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天,

祝您今天过得开心快乐!


That's it for today's sharing.

If you have a unique idea about today’s article,

Welcome to leave us a message,

Let us meet tomorrow,

I wish you a happy day today!



# End #


参考资料:Google翻译、哔哩哔哩

本文由LearningYard学苑整理并发出,如有侵权请在后台留言!




LearningYard学苑

文案| Qian

排版| Qian

审核| Tian

相关推荐

AI「自我复制」能力曝光,RepliBench警示:大模型正在学会伪造身份

科幻中AI自我复制失控场景,正成为现实世界严肃的研究课题。英国AISI推出RepliBench基准,分解并评估AI自主复制所需的四大核心能力。测试显示,当前AI尚不具备完全自主复制能力,但在获取资源...

【Python第三方库安装】介绍8种情况,这里最全看这里就够了!

**本图文作品主要解决CMD或pycharm终端下载安装第三方库可能出错的问题**本作品介绍了8种安装方法,这里最全的python第三方库安装教程,简单易上手,满满干货!希望大家能愉快地写代码,而不要...

pyvips,一个神奇的 Python 库!(pythonvip视频)

大家好,今天为大家分享一个神奇的Python库-pyvips。在图像处理领域,高效和快速的图像处理工具对于开发者来说至关重要。pyvips是一个强大的Python库,基于libvips...

mac 安装tesseract、pytesseract以及简单使用

一.tesseract-OCR的介绍1.tesseract-OCR是一个开源的OCR引擎,能识别100多种语言,专门用于对图片文字进行识别,并获取文本。但是它的缺点是对手写的识别能力比较差。2.用te...

实测o3/o4-mini:3分钟解决欧拉问题,OpenAI最强模型名副其实!

号称“OpenAI迄今为止最强模型”,o3/o4-mini真实能力究竟如何?就在发布后的几小时内,网友们的第一波实测已新鲜出炉。最强推理模型o3,即使遇上首位全职提示词工程师RileyGoodsid...

使用Python将图片转换为字符画并保存到文件

字符画(ASCIIArt)是将图片转换为由字符组成的艺术作品。利用Python,我们可以轻松实现图片转字符画的功能。本教程将带你一步步实现这个功能,并详细解释每一步的代码和实现原理。环境准备首先,你...

5分钟-python包管理器pip安装(python pip安装包)

pip是一个现代的,通用、普遍的Python包管理工具。提供了对Python包的查找、下载、安装、卸载的功能,是Python开发的基础。第一步:PC端打开网址:选择gz后缀的文件下载第二步:...

网络问题快速排查,你也能当好自己家的网络攻城狮

前面写了一篇关于网络基础和常见故障排查的,只列举了工具。没具体排查方式。这篇重点把几个常用工具的组合讲解一下。先有请今天的主角:nslookup及dig,traceroute,httping,teln...

终于把TCP/IP 协议讲的明明白白了,再也不怕被问三次握手了

文:涤生_Woo下周就开始和大家成体系的讲hadoop了,里面的每一个模块的技术细节我都会涉及到,希望大家会喜欢。当然了你也可以评论或者留言自己喜欢的技术,还是那句话,希望咱们一起进步。今天周五,讲讲...

记一次工控触摸屏故障的处理(工控触摸屏维修)

先说明一下,虽然我是自动化专业毕业,但已经很多年不从事现场一线的工控工作了。但自己在单位做的工作也牵涉到信息化与自动化的整合,所以平时也略有关注。上一周一个朋友接到一个活,一家光伏企业用于启动机组的触...

19、90秒快速“读懂”路由、交换命令行基础

命令行视图VRP分层的命令结构定义了很多命令行视图,每条命令只能在特定的视图中执行。本例介绍了常见的命令行视图。每个命令都注册在一个或多个命令视图下,用户只有先进入这个命令所在的视图,才能运行相应的命...

摄像头没图像的几个检查方法(摄像头没图像怎么修复)

背景描述:安防监控项目上,用户的摄像头运行了一段时间有部分摄像头不能进行预览,需要针对不能预览的摄像头进行排查,下面列出几个常见的排查方法。问题解决:一般情况为网络、供电、设备配置等情况。一,网络检查...

小谈:必需脂肪酸(必需脂肪酸主要包括)

必需脂肪酸是指机体生命活动必不可少,但机体自身又不能合成,必需由食物供给的多不饱和脂肪酸(PUFA)。必需脂肪酸主要包括两种,一种是ω-3系列的α-亚麻酸(18:3),一种是ω-6系列的亚油酸(18:...

期刊推荐:15本sci四区易发表的机械类期刊

  虽然,Sci四区期刊相比收录在sci一区、二区、三区的期刊来说要求不是那么高,投稿起来也相对容易一些。但,sci四区所收录的期刊中每本期刊的投稿难易程度也是不一样的。为方便大家投稿,本文给大家推荐...

be sick of 用法考察(be in lack of的用法)

besick表示病了,做谓语.本身是形容词,有多种意思.最通常的是:生病,恶心,呕吐,不适,晕,厌烦,无法忍受asickchild生病的孩子Hermother'sverysi...