personal-picture

本文介绍了Matlab中几种常见图形的绘制方法,包括茎状图、多图绘制、使用text函数添加文字说明、特殊图形绘制等,并通过实例展示了如何利用Matlab实现图形的标识和动态效果。

1.茎状图
在这里插入图片描述

clear all
clc
figure	
t = linspace(-2*pi,2*pi,8); %linspace是Matlab中的一个指令,用于产生x1,x2之间的N点行矢量。其中x1、x2、N分别为起
h = stem(t);
set(h(1),'MarkerFaceColor','blue')
set(h(2),'MarkerFaceColor','red','Marker','square')
%set(H,'PropertyName1',PropertyValue1,'PropertyName2',PropertyValue2,...) 设置句柄为H的图形对象的多个属性PropertyName,PropertyName2,...的对应属性值PropertyValue1,PropertyValue2,....。
% set(H,'color','b');%将窗口颜色改为蓝色


2.多图绘制
在这里插入图片描述

clear all
clc
t1=(0:12)/12*pi;       % 自变量取13个点
y1=sin(t1).*sin(9*t1); % 计算函数值
t2=(0:50)/50*pi;       % 自变量取51个点
y2=sin(t2).*sin(9*t2);
subplot(2,2,1);        % 在子图1上画图
plot(t1,y1,'r.');      % 用红色的点显示
axis([0,pi,-1,1]);     % 定义坐标大小
title('子图1');        % 显示子图标题
% 子图2用红色的点显示
subplot(2,2,2);
plot(t2,y2,'r.');
axis([0,pi,-1,1]); %axis([xmin xmax ymin ymax])
title('子图2')
% 子图3用直线连接数据点和红色的点显示
subplot(2,2,3);
plot(t1,y1,t1,y1,'r.')
axis([0,pi,-1,1]);
title('子图3')
% 子图4用直线连接数据点
subplot(2,2,4);
plot(t2,y2);
axis([0,pi,-1,1]);
title('子图4') 


3.matlab中text 函数
1、作用:可用该函数在图形中指定的位置上显示字符串。
2、使用方法:
如 text(x,y,‘string’):在二维图形中指定的位置(x,y)上显示字符串string
text(x,y,z,‘您好!’) :在三维图形空间中的指定位置(x,y,z)上显示字符串"您好!"
text(x,y,z,‘string’.‘PropertyName’,PropertyValue…) :对引号中的文字string定位于用坐标轴指定的位置,且对指定的属性进行设置。
4.一些线段的选取
在这里插入图片描述

clear all
clc
t=linspace(0,2*pi,100)';                              % 产生100个数
X=[cos(t),cos(2*t),cos(3*t)]+i*sin(t)*[1,1,1];             %100x3的复数矩阵
plot(X),axis square;                                 %使坐标轴长度相同
legend('1','2','3')                                    %图例

在这里插入图片描述
5

.在这里插入图片描述
在这里插入图片描述
6.图形标识
在这里插入图片描述
7特殊图形绘制
在这里插入图片描述
8.实际应用
clear
clc
for j=0:11
axis([-0.7 0.9 -0.9 0.5]);%设置x,y的坐标范围
axis(‘off’);%覆盖坐标刻度

x1=[0 0 0.8 0.8];
y1=[-0.6 -0.8 -0.8 -0.6];%对水槽中的水进行初设置

line([0;0],[0.2;-0.8],‘color’,‘k’,‘linewidth’,3);%水槽左壁的颜色和宽度
line([0;0.8],[-0.8;-0.8],‘color’,‘k’,‘linewidth’,3);%水槽底部的颜色和宽度
line([0.8;0.8],[-0.7;-0.8],‘color’,‘k’,‘linewidth’,3);%水槽右边出水口的下面的颜色和宽度
line([0.8;0.8],[0.2;-0.6],‘color’,‘k’,‘linewidth’,3);%水槽右边出水口的上面的颜色和宽度
line([0.8;0.85],[-0.7;-0.7],‘color’,‘k’,‘linewidth’,3);%出水口的下壁的颜色和宽度
line([0.8;0.85],[-0.6;-0.6],‘color’,‘k’,‘linewidth’,3);%出水口的上壁的颜色和宽度
line(-0.35,0,‘Color’,‘r’,‘linestyle’,’-’, ‘markersize’,20);%给水线处小圆的颜色和尺寸
line(-0.35,-0.6,‘Color’,‘r’,‘linestyle’,’-’, ‘markersize’,20);%警戒线出小圆的颜色和尺寸
line([-0.45;-0.35],[0;0],‘color’,‘k’,‘linewidth’,2);%给水线处线条的颜色和宽度
line([-0.45;-0.35],[-0.6;-0.6],‘color’,‘k’,‘linewidth’,2);%警戒线处线条的颜色和宽度
line([-0.5;-0.5],[0.2,-1],‘color’,‘b’,‘linewidth’,15);%标杆的颜色和宽度
text(-0.9,0,‘给水线’);
text(-0.9,-0.6,‘警戒线’);
text(-0.4,0.5,‘防汛水位检测系统’);
text(0.7,-0.9,‘江河水位’);

water=patch(x1,y1,[0 1 1]);%设置水的颜色及运动路径
ball1=line(0.4,-0.6,‘EraseMode’,‘xor’,‘Color’,‘b’,‘linestyle’,’-’, ‘markersize’,100);
ball2=line(-0.3,-0,‘EraseMode’,‘xor’,‘Color’,‘r’,‘linestyle’,’-’, ‘markersize’,50);
gan=line([-0.3;0.4],[-0;-0.6],‘EraseMode’,‘xor’,‘color’,‘k’,‘linewidth’,1);
%水的上升过程
for i=1:120
a=-0.6+0.005i;
y1=[a -0.8 -0.8 a];
yy1=a;
yy2=-a-0.6;
set(water,‘ydata’,y1);
set(ball1,‘ydata’,yy1);
set(ball2,‘ydata’,yy2);
set(gan,‘ydata’,[yy2 yy1]);%设置两球之间的杆的运动
drawnow;
end
%水的下降过程
for i=1:120
a=-0.005
i;%设置系统运动规律
y1=[a -0.8 -0.8 a];%设置水的下降运动过程
yy1=a;%设置水槽中小球的下降运动过程
yy2=-a-0.6;%设置标杆处小球的下降运动过程
set(water,‘ydata’,y1);%设置水的下降运动
set(ball1,‘ydata’,yy1);%设置水槽中小球下降的运动
set(ball2,‘ydata’,yy2);%设置标杆处小球的下降运动
set(gan,‘ydata’,[yy2 yy1]);%设置两球之间的杆的下降运动
drawnow;
end
water=patch(x1,y1,[0 1 1]);%设置水的颜色及运动路径
ball1=line(0.4,-0.6,‘EraseMode’,‘xor’,‘Color’,‘b’,‘linestyle’,’-’, ‘markersize’,100);%设置水槽中小球的颜色、大小和擦除方式
ball2=line(-0.3,-0,‘EraseMode’,‘xor’,‘Color’,‘r’,‘linestyle’,’-’, ‘markersize’,50);%设置标杆处小球的颜色、大小和擦除方式
gan=line([-0.3;0.4],[-0;-0.6],‘EraseMode’,‘xor’,‘color’,‘k’,‘linewidth’,1);%设置两球之间连线的颜色、大小和擦除方式
end在这里插入图片描述

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Poetry·Music·Gaming - Personal Webpage</title> <style> /* Global styles */ :root { --primary: #1a1a2e; --secondary: #0f3460; --accent: #e94560; --text: #f1f1f1; } * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: 'Lato', sans-serif; background: linear-gradient(135deg, var(--primary), #16213e); color: var(--text); line-height: 1.6; padding: 20px; } .container { max-width: 1200px; margin: 0 auto; } section { background: rgba(10, 10, 20, 0.7); border-radius: 15px; padding: 30px; margin-bottom: 30px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); backdrop-filter: blur(10px); } h1, h2 { color: var(--accent); margin-bottom: 20px; text-shadow: 0 2px 4px rgba(0,0,0,0.5); } /* Poem section */ .poem { font-family: 'Playfair Display', serif; text-align: center; padding: 30px 0; } .poem-title { font-size: 2.5rem; margin-bottom: 10px; letter-spacing: 1px; } .poem-author { font-size: 1.2rem; opacity: 0.8; margin-bottom: 30px; font-style: italic; } .poem-content { font-size: 1.5rem; line-height: 2.2; letter-spacing: 0.5px; } .poem-line { margin: 15px 0; } /* MV player */ .player-container { position: relative; border-radius: 12px; overflow: hidden; margin: 30px 0; box-shadow: 0 10px 30px rgba(0,0,0,0.5); } .mv-frame { width: 100%; height: 500px; border: none; } /* Game intro section */ .game-info { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 30px; } .game-text { padding: 20px; } .game-features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin: 20px 0; } .feature-card { background: rgba(233, 69, 96, 0.15); padding: 15px; border-radius: 8px; border-left: 3px solid var(--accent); } .screenshot { border-radius: 10px; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.4); display: flex; align-items: center; } .screenshot img { width: 100%; height: auto; display: block; } /* Responsive design */ @media (max-width: 768px) { .game-info { grid-template-columns: 1fr; } .mv-frame { height: 300px; } .poem-content { font-size: 1.3rem; } } </style> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Playfair+Display:wght@700&display=swap" rel="stylesheet"> </head> <body> <div class="container"> <!-- Header --> <header> <h1>Poetry · Music · Gaming</h1> <p>Where Classical Poetry Meets Modern Esports</p> </header> <!-- Poem Section --> <section id="poem"> <h2>"Ascending the Heights" - Du Fu (Tang Dynasty)</h2> <div class="poem"> <div class="poem-title">Ascending the Heights</div> <div class="poem-author">By Du Fu (712-770 AD)</div> <div class="poem-content"> <div class="poem-line">The wind so swift, the sky so wide, apes wail and cry;</div> <div class="poem-line">Water so clear and beach so white, birds wheel and fly.</div> <div class="poem-line">The boundless forest sheds its leaves shower by shower;</div> <div class="poem-line">The endless river rolls its waves hour after hour.</div> <div class="poem-line">A thousand miles from home, I'm grieved at autumn's plight;</div> <div class="poem-line">Ill now and then for years, alone I'm on this height.</div> <div class="poem-line">Living in times so hard, at frosted hair I pine;</div> <div class="poem-line">Cast down by poverty, I have to give up wine.</div> </div> </div> <p style="text-align: center; margin-top: 20px; font-style: italic;">Translated by Xu Yuanchong</p> </section> <!-- Music MV Section --> <section id="music"> <h2>"Ticking Away" - Valorant Champions 2023 Theme</h2> <div class="player-container"> <iframe width="560" height="315" src="https://www.youtube.com/embed/CdZN8PI3MqM?si=iaAwrEvd_YR1UxGH" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> </div> <div class="music-info"> <p><strong>Artist:</strong> Riot Games Music Team</p> <p><strong>Released:</strong> August 6, 2023</p> <p><strong>Event:</strong> Valorant Champions 2023 Grand Finals</p> <p><strong>Description:</strong> The official anthem for the 2023 Valorant Champions Tour, capturing the intensity and global spirit of the tournament.</p> </div> </section> <!-- Game Introduction Section --> <section id="game"> <h2>Valorant - Tactical Shooter Masterpiece</h2> <div class="game-info"> <div class="game-text"> <p>Valorant is a free-to-play tactical first-person shooter developed and published by Riot Games. Combining precise gunplay with unique character abilities, it has become a premier esports title since its 2020 release.</p> <div class="game-features"> <div class="feature-card"> <h3>Agent System</h3> <p>20+ unique Agents with special abilities</p> </div> <div class="feature-card"> <h3>Weapon Arsenal</h3> <p>17 weapons across 6 categories</p> </div> <div class="feature-card"> <h3>Competitive</h3> <p>Ranked mode with VCT global tournaments</p> </div> <div class="feature-card"> <h3>Map Design</h3> <p>7 tactically diverse maps</p> </div> </div> <h3>Core Gameplay</h3> <p>Matches are 25-round games where attackers try to plant a Spike while defenders attempt to stop them. The economy system forces strategic buying decisions each round. Valorant's 128-tick servers ensure precise hit registration where every millisecond counts[^1].</p> <h3>Esports Impact</h3> <p>Valorant Champions Tour (VCT) features international tournaments with millions in prizes. The 2023 Champions in Los Angeles set viewership records with over 1.4 million concurrent viewers[^2].</p> </div> <div class="screenshot"> <img src="https://images.contentstack.io/v3/assets/bltb6530b271fddd0b1/blt158572a7e9a2121e/62a0940b7fdb2a6d4f0dbb80/V_AGENTS_587x900_Brimstone.png" alt="Valorant Agent Brimstone"> </div> </div> </section> <!-- Footer --> <footer> <p>© 2023 Poetry · Music · Gaming | Fusion of Classical and Modern Culture</p> </footer> </div> </body> </html> 这是我的网页代码,现在我要让视频位置和尺寸合适,给出修改后的代码
06-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值