当前位置:文档之家› 东南大学matlab第三次大作业

东南大学matlab第三次大作业

东南大学matlab第三次大作业
东南大学matlab第三次大作业

Matlab Worksheet 3

Part A

1. Using function conv_m.m to make convolution between the following to functions (x and h):

x=[3, 11, 7, 0, -1, 7, -5, 0, 2]; h=[11, 9, 0, -7, -3, 2, 0 -1]; nx=[-2:6]; nh=[0:7];

Plot the functions and convolution results.

x=[3, 11, 7, 0, -1, 7,5,0, 2]; nx=[-2:6];

h=[11, 9, 0, -7, -3,2,0,-1]; nh=[0:7];

[y, ny]=conv_m(x,nx,h,nh); subplot(3,1,1); stem(nx,x); ylabel('x[n]');

axis([-6 10 -20 20]); subplot(3,1,2); stem(nh,h); ylabel('h[n]');

axis([-4 10 -20 20]); subplot(3,1,3); stem(ny,y); xlabel('n'); ylabel('y[n]');

axis([-6 15 -200 200]);

2. Plot the frequency response over π≤Ω≤0for the following transfer function by letting

Ω=j e z , where Ωis the frequency (rad/sample)., with appropriate labels and title.

9

.06.1)(2++=z z z

z H .

delta=0.01;

Omega=0:delta:pi;

H= (exp(j .* Omega)) ./ ((exp(j .* Omega)).^2+1.6*exp(j .* Omega)+0.9); subplot(2,1,1);

plot(Omega, abs(H)); xlabel('0<\Omega<\pi'); ylabel('|H(\Omega)|');

axis([0 pi 0 max(abs(H))]); subplot(2,1,2);

plot(Omega,atan2(imag(H),real(H))); xlabel('0<\Omega<\pi');

ylabel(' -\pi < \Phi_H <\pi') axis([0 pi -pi pi]);

3. Use fft to analyse following signal by plotting the original signal and its spectrum.

??

? ??

+??? ??+??? ??=10244672sin 10241372sin 1024322sin ][n n n n x πππ.

% fft N=1024; dt=1/N;

t=0:dt:1-dt;

x=sin(2*pi*32 .*t) +sin(2*pi*137 .*t)+sin(2*pi*467 .*t) ; subplot(2,1,1);

plot(t,x), xlabel('t sec'),ylabel('x'); title('Signal and its Fourier Transform'); axis([min(t) max(t) 1.5*min(x) 1.5*max(x)]); X=fft(x); f=0:N-1;

subplot(2,1,2);

stem(f,abs(X)), xlabel('Hz'), ylabel('|X|'); axis([ 0 N/2 0 1.5*max(abs(X))]);

4. Use the fast Fourier transform function fft to analyse following signal. Plot the original signal,

and the magnitude of its spectrum linearly and logarithmically. Apply Hamming window to reduce the leakage.

??? ?

?

+??? ??+??? ??=10247.4672sin 10244.1372sin 10245.322sin ][n n n n x πππ.

The hamming window can be coded in Matlab as

for n=1:N

hamming(n)=0.54+0.46*cos((2*n-N+1)*pi/N); end;

where N is the data length in the FFT.

%Examine signal components %sampling rate 1024Hz N=1024; dt=1/N;

t=0:dt:1-dt;

%****define the signal**

x=0.1*sin(2*pi*32.5 .*t ) + ... 0.2*sin(2*pi*137.4 .*t )+ ... 0.15*sin(2*pi* 467.7 .*t ) ; %*********************** subplot(3,1,1); plot(t,x);

axis([0 1 -1 1]);

xlabel('nT (seconds)'); ylabel('x[n]');

%hamming window for n=1:N

w(n)=0.54+0.46*cos((2*n-N+1)*pi/N); end ;

x1=x .*w;

subplot(3,1,2); plot(t,x1);

axis([0 1 -5 5]);

xlabel('nT (seconds)'); ylabel('x[n] Hamming win'); X=fft(x1);

df=1;

f=0:df:N-1;

subplot(3,1,3);

plot(f,20*log10(abs(X))); axis([0 N/2 -60 60]);

xlabel('k (Hz)');

ylabel('|X[k]| (db)');

Part B

Simulation Using SIMULINK

INTRODUCTION

The objective of this laboratory is to learn about various properties of signals and systems by doing simulations in SIMULINK.

PART 1. BASICS OF SIMULINK

1.1 UNDERSTANDING SIMPLE WAVEFORMS AND INTEGRATION

Create a pulse of height 2 units from time 0 to 4 seconds by subtracting two unit steps and adding a gain. Connect this pulse to an integrator with a gain of 0.5 and a zero initial condition. Connect oscilloscopes to show the pulse and the output of the integrator. You may wish to name your simulation (block) diagram; to do so use the save as feature under edit. Your block diagram should be similar as below.

Before simulating you need to pull down the simulation header and double click on parameters. Unless told otherwise always assume that you can use the ode 45 integration algorithm shown in this window and the other default parameters. Typically you will only alter the start and stop times but for this first simulation you can use the default values of 0 and 10 seconds. Double click on the oscilloscopes to get the windows in which the traces will appear, pull down the simulate menu and click on run. Plot below the integrator input and output waveforms.

Repeat the experiment but with an initial condition of –2 on the integrator. Again draw the results.

Repeat the experiment but with an initial condition of –2 on the integrator. Again draw the results.

1.2 FIRST ORDER SYSTEM

A single time constant may be simulated using the transfer function block in which you enter the coefficients of the numerator and denominator polynomials. Set up the configuration in a new SIMULINK window to realise the transfer function 1/(s+2) with the input unit step and an oscilloscope connected to the output of the transfer function block. Plot the block diagram in the space below. Simulate the system for 5 seconds and plot the response.

1.3 SECOND ORDER SYSTEM

For the second order all pole transfer function )2/(2

00220ωωζω++s s you will recall that if a time scale of ω0t is used for plotting the step response, the response shape will only be affected by changes in the damping ratio ζ. This can also be shown if we normalise the transfer function by replacing (s/ω0) by s n to

give )12/(12

++n n s s ζ. To study the effect of varying ζ on the step response we will therefore use the transfer function 1/(s 2+2ζs+1). Set up the following configuration for a simulation study.

i) A unit step input. ii) Connect the unit step to a transfer function of 1/(s 2+2ζs+1) with ζ = 1.0. iii) Take a summing block and connect the input step to a +ve input and the transfer function

output to a –ve input.

iv) Connect the output of this summer to a square function. This is obtained by using f(u) in the

nonlinear blocks.

v)Connect the output of this squarer to an integrator.

vi)Connect two oscilloscopes to the circuit, one to the transfer function output and the other to the output of the integrator.

vii)Also connect simout blocks to the same signals as the oscilloscopes. Rename the one connected to the integrator output simout1.

Simulate the system with the values of ζ listed in the table below and fill in the other figures from the simulation results. To get an accurate value at the end of each run you can type simout1 in the MATLAB window. You can also measure the overshoot by making use of the maximum command: simply type max(simout) in the MATLAB window.

% overshoot 2.1076 1.2500 1.1778 1.0571 1.0000 1.1285 2.1431

PART 2. SIMULATION OF AIRCRAFT PITCH ANGLE AND ALTITUTE

The purpose IS to use "SIMULINK" to simulate a (much simplified) model of the longitudinal motion of a fighter aircraft.

The "angle of attack", is the angle between the direction a plane is pointing, and the direction in which it actually moves through the air. For a plane flying at approximately constant altitude, this is equivalent to the "pitch angle", φ, as illustrated in Fig.2.1. This angle is important because it produces a lift force perpendicular to the axis of the plane, and hence a "normal acceleration", a n , (also shown in the figure).

v

The pilot wants to be able to control the pitch angle (倾斜角度), and does so ultimately by rotating the front fins, and tail elevators of the aircraft, shown in Fig. 2.2. The first task is therefore to model the

effect of these movements on the "pitch rate" q (

)=φ

, and "normal acceleration" a n .

Fig. 2.2 Illustration of control surfaces

2.1: MODELLING THE AIRCRAFT AND ACTUATOR DYNAMICS

i) Normal Acceleration, a n

The acceleration of the aircraft in a direction perpendicular to its axis, (the "normal accel.", a n ), is determined mainly by the angle θ1 of the tail elevators of the aircraft shown in Fig. 2.2. Indeed aerodynamic modelling shows that this relationship can be described by the differential equation,

11116342.364.1982.81.3θθθ++=-+ n n n a a a

Convert this relationship into a transfer function form:-

ii) Pitch Rate, q

The rate at which the pitch angle changes, (the "pitch rate", q ), is determined mainly by the angle θ2 of the front fins of the aircraft shown in Fig. 2.2. Indeed aerodynamic modelling shows that this relationship can be described by the differential equation,

2

227.1125.782.81.3θθ++=-+ q q q

Convert this relationship into a transfer function form:-

iii) Actuator Dynamics + Gears

The tail elevators of the aircraft are driven directly by a hydraulic actuator which has a transfer function,

G s s ()()=-+1414/ (3)

To a unit step input U(s)=1/s , the response R(s) = G(s)?U(s)= 14

1

1)14(14++-=+-s s s s . What form of

step response r(t) would you expect from this actuator, and what is its time constant?

The front fins and the tail elevators are both driven from the actuator by the same drive shaft through a gear box. The same gear on this drive shaft connects to the tail elevator gear wheel, which has 500 teeth, and the front fin gear wheel, which has 100 teeth, the relationship between θ1 and θ2 is

52

1

12==t t θθ

(4) 2.2: SIMULATING THE AIRCRAFT AND ACTUATOR DYNAMICS

i) F or the aircraft model you will need from the Continuous or Maths Library:-

?

a Transfer Fcn block to represent the "tail elevator angle → normal accel" relationship (eqn (1))

? a Transfer Fcn block to represent "front fin angle → pitch rate" relationship, (see eqn (2)) ? a Transfer Fcn block to represent the hydraulic "actuator dynamics", (see eqn (3)) ? a Gain block to represent the "gears", (see eqn (4))

from the Sources Library:-

? a Step Input block to act as a test input - (set Step time = 5sec, and Final value = 0.01 rad)

from the Sinks Library:- ?

a ‘Scope block to monitor the pitch rate output - (set Horizontal Range = 20sec).

ii) Now connect the blocks together, using the step input to drive the actuator, and the actuator to drive the tail elevators. The actuator is also used to drive the front fins via the gearbox. The 'Scope should be connected to the output of the "front fin angle → pitch rate" block. Note: you can take a branch from a signal line by dragging with the right mouse button from the point on the line at which you want the branch to start.

Plot the block diagram you have created in the box below:-

iii) From the pull-down menus of your simulation window, select Simulation/Parameters , in order to define how the simulation is to be performed. Set:-

Stop Time = 20 sec; Initial Step Size = 0.001; Max Step Size = 0.01;

iv) Finally double click on your ‘scope, so that you can watch the progress of the simulation, and then select Simulation/Start from the pull-down menu of your simulation window. You may want to adjust

the Vertical Range of your 'Scope, and re-run the simulation to get a good picture. Plot the response of the aircraft pitch rate below, and comment on these results. Note that it can be shown that if a transfer function has a denominator polynomial with a zero or negative coefficient then it must have a root with a zero or positive real part.

2.3: SIMULATING THE PITCH RATE CONTROL SYSTEM

The designers are quite glad they simulated the response of the aircraft, before trying it for real. They now decide to improve the response by measuring the output (ie. what is actually happening to the pitch rate), and subtracting this from the input (ie. what they would like to happen), to produce an error signal. The error signal will be amplified, and then used to drive the actuator (see Fig. 2.3). In this way the actuator will automatically act so as to reduce any differences between the input demand, and the output response.

Fig. 2.3 Feedback control of pitch rate

i) Before you simulate the control system described above, you will probably find that you are short of space in your simulation window. Besides it would be nice to package the aircraft + actuator dynamics as a single block, so that they are distinct from anything added later as shown in Fig. 2.3.

If you press the left mouse button in an empty space of the window, you get a "rubber band" box which you can drag to surround a group of elements. When you release the button, all elements inside are "selected". Use this technique to select all the aircraft + actuator dynamics, (but leave out the step input and ‘scope monitor). From the pull-down menu under Edit select Create a Subsystem, and your diagram will suddenly look as shown in Fig. 2.4.

Fig. 2.4 New diagram

ii) Rename the "Subsystem" as "Actuator + Aircraft Dynamics" as shown in Fig. 2.3 by editing the text below the block. You can see what is inside by double clicking on the block itself, - try it! Notice that the input and output connections are labelled "in_1", "out_1" etc. Edit these to give them more meaningful names.

iii) Now construct the planned control system, as illustrated in Fig. 2.3. Notice the pilot is now represented by a Signal Generator (from the Sources library), which should be set to produce a Square Wave, of frequency 0.1 Hz and peak amplitude 0.5.

iv) The designers are unsure what value to use for the Gain. Open the Pitch Rate 'Scope, and run the simulation first for the Gain = -0.5 (as shown above), and then for the Gain = -5. Plot the two responses you obtain, and comment on the relative advantages and disadvantages of each:-

Comments on responses (in terms of overshot and response time etc):

PART 3: SIMILATION OF NONLINEAR SHIP ROLL DYNAMICS

The rolling motion of ships is of considerable interest to naval architects because even today around 50% of ships lost at sea, sink as a result of a capsize. The aim of this laboratory is to study such behaviour by:-

?constructing a nonlinear differential equation model for the system

?converting this model into a phase variable block diagram form suitable for simulation

?simulating the (nonlinear) response to sinusoidal excitation

?calculating the steady state response for a ship whose cargo has shifted dangerously to one side

Fig. 3.1 Ship schematic

3.1: MODELLING AND SIMULATION OF SHIP DYNAMICS

i) Consider the ship sketch shown in Fig. 3.1. Given that:-

? The effective inertia of the ship about its roll axis = J (1) ? The damping moment / torque due to friction between the body of the ship and the water, and

due to turbulence round the "bilge keels" = c c 12

3 θθ+ (2) ? The restoring moment / torque due to the buoyancy and shape of the ship, as it is pushed to one

side = k k k 12335θθθ++ (3) ? The input / forcing moment due to the wave forces acting on the ship = u t ()

- Using Newton’s second law of motion ∑

=Torque Moment J / θ , the nonlinear differential equation which describes the rolling motion of the ship can be written as:-

()(

)

53

321321)(θθθθθθk k k c c t u J ++-+-= (4)

(ii) Re-arrange equation (4) to obtain an expression for the highest derivative of the output signal θ

:-

()

()()

53

321321)(1θθθθθθk k k c c t u J

++-+-= (5)

iii) Hence complete the drawing of the SIMULINK block diagram for the ship roll system:-

3.2: SIMULATING THE SHIP DYNAMICS

i) For the ship model you will need:-

from the Continuous and Maths Library:- ? a few Integrator blocks - (assume zero initial conditions for now) ? a few Gain blocks (not absolutely necessary) from the Nonlinear Library:-

? a couple of Fcn blocks to implement the damping and stiffness terms (eqns (2), and (3)) from the Sources Library:-

? a Sine Wave block to simulate the sea waves u(t) - (set Ampl = 0.3 , and Freq = 0.6 rad/s) from the Sinks Library:-

?

a To Workspace block for the output ship roll angle, θ, of the simulation. This stores the results in a MATLAB variable which we can plot later, -(set the Variable name = theta, and the Maximum number of timesteps (ie points stored) = 5000)

? an oscilloscope if you wish to see a waveform whilst the simulation is taking place

ii) Drag the appropriate blocks over into your simulation window using the mouse, and double click on them to enter the appropriate parameter values. The numerical values for the coefficients of eqn (4) are:-

;150;20;8.0;8.0;02.0;132121======k k k c c J (6)

Note these values are given in consistent units so that θ is in radians. Finally by clicking on the text under each block, you can also enter a suitable description for each.

iii) Now connect the blocks together, according to the phase variable block diagram you have plotted in section A. Note that some blocks will need changing so they "face the other way"; you can do this by selecting the block and "Flipping Horizontally " using the Options pulldown menu. Remember too that you can take a branch from a signal line by dragging with the right mouse button from the point on the line at which you want the branch to start.

iv) From the pull-down menus of your simulation window, select Simulation/Parameters , in order to define how the simulation is to be performed. Set:-

Stop Time = 10*pi (sec); Initial Step Size = 0.001; Max Step Size = 0.1;

v) Now run the simulation by selecting Simulation/Start from the pull-down menu of your simulation window. If you do not use an oscilloscope you probably won't see much happening because the results are being stored in the MATLAB variable called 'theta', instead of being displayed immediately. After a few seconds however, you should hear a slight beep indicating the simulation is complete. Use of an oscilloscope is, however, recommended so that you can see if things ‘look all right’.

vi)Now plot your results by typing plot(theta)at the MATLAB prompt in the MATLAB command window. Plot the response below, and comment on how it differs from what you would expect from a linear system if this were also excited with a sine wave input.

matlab期末大作业

电气学科大类 Modern Control Systems Analysis and Design Using Matlab and Simulink Title: Automobile Velocity Control Name: 巫宇智 Student ID: U200811997 Class:电气0811

电气0811 巫宇智 Catalogue Preface (3) The Design Introduction (4) Relative Knowledge (5) Design and Analyze (6) Compare and Conclusion (19) After design (20) Appendix (22) Reference (22)

Automobile Velocity Control 1.Preface: With the high pace of human civilization development, the car has been a common tools for people. However, some problems also arise in such tendency. Among many problems, the velocity control seems to a significant challenge. In a automated highway system, using the velocity control system to maintain the speed of the car can effectively reduce the potential danger of driving a car and also will bring much convenience to drivers. This article aims at the discussion about velocity control system and the compensator to ameliorate the preference of the plant, thus meets the complicated demands from people. The discussion is based on the simulation of MATLAB. Key word: PI controller, root locus

春MATLAB仿真期末大作业

MATLAB仿真 期末大作业 姓名:班级:学号:指导教师:

2012春期末大作业 题目:设单位负反馈控制系统前向通道传递函数由)()(21s G s G 和串联,其中: ) 1(1)()(21++==s A s G s K s G A 表示自己学号最后一位数(可以是零),K 为开环增益。要求: (1)设K=1时,建立控制系统模型,并绘制阶跃响应曲线(用红色虚线,并标注坐标和标题);求取时域性能指标,包括上升时间、超调量、调节时间、峰值时间; (2)在第(1)问中,如果是在命令窗口绘制阶跃响应曲线,用in1或者from workspace 模块将命令窗口的阶跃响应数据导入Simulink 模型窗口,用示波器显示阶跃响应曲线;如果是在Simulink 模型窗口绘制阶跃响应曲线,用out1或者to workspace 模块将Simulink 模型窗口的阶跃响应数据导入命令窗口并绘制阶跃响应曲线。 (3)用编程法或者rltool 法设计串联超前校正网络,要求系统在单位斜坡输入信号作用时,速度误差系数小于等于0.1rad ,开环系统截止频率s rad c /4.4''≥ω,相角裕度大于等于45度,幅值裕度大于等于10dB 。

仿真结果及分析: (1)、(2)、将Simulink模型窗口的阶跃响应数据导入命令窗口并绘制阶跃响应曲线 通过在Matlab中输入命令: >> plot(tout,yout,'r*-') >> title('阶跃响应曲线') 即可得出系统阶跃响应曲线,如下: 求取该控制系统的常用性能指标:超调量、上升时间、调节时间、峰值时间的程序如下: G=zpk([],[0,-1],5)。 S=feedback(G,1)。

matlab微积分基本运算

matlab 微积分基本运算 §1 解方程和方程组解 1. 线性方程组求解 对于方程 AX = B ,其中 A 是( m ×n )的矩阵有三种情形: 1)当n=m 且A 非奇异时,此方程为“恰定”方程组。 2)当 n > m 时,此方程为“超定”方程组。 3)当n

0.3188 两种方法所求方程组的解相同。 (2)MATLAB 解超定方程AX=B 的方法 对于方程 AX = B ,其中 A 是( m ×n )的矩阵, n > m ,如果A 列满秩,则此方程是没有精确解的。然而在实际工程应用中,求得其最小二乘解也是有意义的。基本解法有: 1)采用求伪逆运算解方程 x=pinv(A)*B 说明:此解为最小二乘解x=inv(A ’*A)*A*B,这里pinv(A) =inv(A ’*A)*A. 2)采用左除运算解方程 x=A\B 例2 “求伪逆”法和“左除”法求下列方程组的解 ??? ??=+=+=+1 221421 221 2121x x x x x x 命令如下: >> a=[1 2;2 4;2 2]; >> b=[1,1,1]'; >> xc=a\b %用左除运算解方程 运行得结果: xc = 0.4000 0.1000 >> xd=pinv(a)*b %用求伪逆运算解方程 运行得结果: xd = 0.4000 0.1000 >> a*xc-b %xc 是否满足方程ax=b 运行得结果: ans = -0.4000 0.2000 0.0000 可见xc 并不是方程的精确解。 (3) MATLAB 解欠定方程AX=B 的方法 欠定方程从理论上说是有无穷多个解的,如果利用求“伪逆”法和“左除”法来求解,只能得到其中一个解。基本方法: 1)采用求伪逆运算解方程 x=pinv(A)*B 2)采用左除运算解方程

期末大作业报告

期末大作业报告 课程名称:数字图像处理 设计题目:车牌识别 学院:信息工程与自动化学院 专业:计算机科学与技术 年级:xxxxx 学生姓名:xxxxxxx(学号xxxxxxxxxxxxx) 指导教师:xxxx 日期:20XX.6.10 教务处制 车牌识别 摘要:数字图像处理技术是20世纪60年代发展起来的一门新兴学科,随着图像处理理论和方法的进一步完善,使得数字图像处理技术在各个领域得到了广泛应用,并显示出广阔的应用前景。MATLAB既是一种直观、高效的计算机语言,同时又是一个科学计算平台。它为数据分析和数据可视化、算法和应用程序开发提供了最核心的数学和高级图形工具。根据它提供的500多个数学和工程函数,工程技术人员和科学工作者可以在它的集成环境中交互或编程以完成各自的计算。MATLAB中集成了功能强大的图像处理工具箱。由于MA TLAB语言的语法特征与C语言极为相似,而且更加简单,更加符合科技人员对数学表达式的书写格式,而且这种语言可移植性好、可扩展性强,再加上其中有丰富的图像处理函数,所以MA TLAB在图像处理的应用中具有很大的优势。车牌识别技术是智能交通系统的重要组成部分,在近年来得到了很大的发展。本文从预处理、边缘检测、车牌定位、字符分割、字符识别五个方面,具体介绍了车牌自动识别的原理。并用MATLAB软件编程来实现每一个部分,最后识别出汽车牌照。 关键词:车牌识别、数字图像处理、MATLAB

一、设计原理 车辆牌照识别系统的基本工作原理为:将摄像头拍摄到的包含车辆牌照的图像通过视频卡输入到计算机中进行预处理,再由检索模块对牌照进行搜索、检测、定位,并分割出包含牌照字符的矩形区域,然后对牌照字符进行二值化并将其分割为单个字符,然后输入JPEG或BMP 格式的数字,输出则为车牌号码的数字。牌照自动识别是一项利用车辆的动态视频或静态图像进行牌照号码、牌照颜色自动识别的模式识别技术。其硬件基础一般包括触发设备、摄像设备、照明设备、图像采集设备、识别车牌号码的处理机等,其软件核心包括车牌定位算法、车牌字符分割算法和光学字符识别算法等。某些牌照识别系统还具有通过视频图像判断车辆驶入视野的功能称之为视频车辆检测。一个完整的牌照识别系统应包括车辆检测、图像采集、牌照识别等几部分。当车辆检测部分检测到车辆到达时触发图像采集单元,采集当前的视频图像。牌照识别单元对图像进行处理,定位出牌照位置,再将牌照中的字符分割出来进行识别,然后组成牌照号码输出。 二、设计步骤 1. 提出总体设计方案: (1)车牌图像预处理方法 因为车牌图像都是在室外拍摄的,所以不可避免地会受到光照、气候等因素的影响,而且拍摄者的手部抖动与车辆的移动会造成图像的模糊。要去除这些干扰就得先对车牌图像进行预处理。由于当前数码相机的像素较高,原始图像的数据一般比较大,输入的彩色图像包含大量颜色信息,会占用较多的存储空间,且处理时也会降低系统的执行速度。因此对图像进行识别等处理时,常将彩色图像转换为灰度图像,以加快处理速度。对图像进行灰度化处理后常用的方法是图像二值化、去除背景图像、增强处理、边缘检测、滤波等处理等。

(完整版)Matlab学习系列15.数值计算—高数篇

15. 数值计算—高数篇 一、求极限 limit(f,x,a)——求极限 lim ()x a f x → limit(f,x,a,'right')——求右极限 lim ()x a f x +→ limit(f,x,a,'left')——求左极限 lim ()x a f x -→ 例1 求 2352 lim sin 53x x x x →∞++ 代码: syms x; y=(3*x^2+5)/(5*x+3)*sin(2/x); limit(y,x,inf) 运行结果:ans = 6/5 注:Matlab 求二元函数的极限,是用嵌套limit 函数实现的,相当于求的是累次极限,需要注意:有时候累次极限并不等于极限。 例2 求 30 lim 2x x x x a b +→?? + ??? 代码: syms x a b; y=((a^x+b^x)/2)^(3/x); limit(y,x,0,'right') 运行结果:ans = a^(3/2)*b^(3/2) 二、求导 diff(f,x,n)——求函数f 关于x 的n 阶导数,默认n=1

例3 求1sin 1cos x y x += +的1阶导数,并绘图 代码: syms x a b; y=((a^x+b^x)/2)^(3/x); limit(y,x,0,'right') 运行结果: y1 = cos(x)/(cos(x) + 1) + (sin(x)*(sin(x) + 1))/(cos(x) + 1)^2 例4 设sin xy z e =,求2,,z z z x y x y ??????? 代码: syms x y; z=exp(sin(x*y)); zx=diff(z,x) zy=diff(z,y) zxy=diff(zx,y) % 也等于diff(zy,x) -5 5 5 10 15 20 25 x (sin(x) + 1)/(cos(x) + 1) -5 05 -20 -15 -10-5 05 10 1520 25x cos(x)/(cos(x) + 1) + (sin(x) (sin(x) + 1))/(cos(x) + 1) 2

《科学计算与MATLAB》期末大作业

杭州电子科技大学信息工程学院《科学计算与MATLAB》期末大作业

给出程序、图、作业分析,程序需加注释。 1. 试编写名为fun.m 的MATLAB 函数,用以计算下述的值: ?? ? ??-<->=t t n t t t n t f 的)4/sin()(si 对所有)4/sin(其他情况)sin(的)4/sin()(si 对所有)4/sin()(ππππ 绘制t 关于函数f(t)的图形,其中t 的取值范围为ππ66≤≤-t ,间距为10/π。 function y=fun()%定义函数 % t=-6*pi:pi/10:6*pi; %定义变量范围 y = (sin(pi/4)).*(sin(t)>sin(pi/4))+(sin(-pi/4)).*(sin(t)=sin(-pi/4)));%函数表示 plot(t,y); %画图 end

2.解以下线性方程组 ??? ??=+=++=--3 530 42231 321321x x x x x x x x A=[2 -1 -1;1 1 4;3 0 5];%输入矩阵 B=[2;0;3]; %输入矩阵 X = A\B %计算结果 3.已知矩阵? ? ??? ???? ???=44434241 3433323124232221 14131211A 求: (1)A(2:3,2:3) (2)A(:,1:2) (3)A(2:3,[1,3]) (4)[A,[ones(2,2);eye(2)]]

A=[11 12 13 14;21 22 23 24;31 32 33 34;41 42 43 44];%输入矩阵A(2:3,2:3) %输出矩阵 A(:,1:2) %输出矩阵 A(2:3,[1,3]) %输出矩阵 [A,[ones(2,2);eye(2)]] %输出矩阵

MATLAB期末大作业模板

MATLAB应用技术 期末大作业 专业: 姓名: 学号: 分数

一、在一个图形窗口中以子图形式同时绘制正弦、余弦、正切、余切曲线。请写下完整代码,展示图形结果。(请标注题图和坐标轴,用不同颜色和不同线型分别绘制以上曲线)。(15分) 二、某公司员工的工资计算方法如下。 (1)工作时数超过120小时者,超过部分加发15%。 (2)工作时数低于60小时者,扣发700元。 (3)其余按每小时84元发。 根据员工的工时数,计算应发工资。请写下完整的程序代码,并任意输入一工时数(使用input 函数),将结果展示(使用disp 函数)利用该代码进行计算工资,请写下计算结果。(15分) 三、编写一个函数文件,使其能够产生如下的分段函数: ?? ? ??≥<<≤-=66225.0,25.05.15.0)(x x x x x x f 请编写完整的函数文件(保存函数文件名为hanshu.m ),并编写脚本文件代码,任意输入x 值(使用input 函数),在脚本文件中调用函数文件求)(x f ,展示结果(使用disp 函数),请写下计算结果。(15分) 四、将5个学生的6门功课的成绩存入矩阵P 中,进行如下处理: (1)分别求每门课的最高分、最低分及相应学生的序号。 (2)分别求每门课的平均分和标准差。 (3)5门课总分的最高分、最低分及相应学生序号。 (4)将5门课总分按从大到小顺序存入score 中,相应学生序号存入num 。 请将各小题的运行代码完整写下来,并写下运行结果。(20分) 五、请利用所学的MATLAB 知识,自主设计一个图形用户界面,请完整记录它的设计过程,需提供文字、代码和图片,以充分说明设计的图形用户界面可实现

高等数学实验报告matlab

西安交通大学 高等数学 实验报告 班级 组员与学号 2013年

实验名称:学生成绩管理 一、实验目的 二、实验内容 三、详细编程 clear for i=1:10 a{i}=89+i; b{i}=79+i; c{i}=69+i; d{i}=59+i; end c=[d,c]; Name=input('please input name:'); Score=input('please input score:'); n=length(Score); Rank=cell(1,n); S=struct('Name',Name,'Score',Score,'Rank',Rank); for i=1:n switch S(i).Score case 100 S(i).Rank='满分'; case a S(i).Rank='优秀'; case b S(i).Rank='良好'; case c S(i).Rank='及格'; otherwise S(i).Rank='不及格'; end end disp(['学生姓名 ','得分 ','等级']);

for i=1:n disp([S(i).Name,blanks(6),num2str(S(i).Score),blanks(6),S(i).Rank]); end s=0; for i=1:n s=S(i).Score+s; end averscore=s/n; t=S(1).Score; for i=1:(n-1) if(S(i).ScoreS(i+1).Score) m=S(i+1).Score; end end disp(['平均成绩']); disp([averscore]); disp(['最高分']); disp(t); disp(['最低分']); disp(m); 四、实验结果

matlab综合大作业(附详细答案)

m a t l a b综合大作业(附详细 答案) 标准化文件发布号:(9312-EUATWW-MWUB-WUNN-INNUL-DQQTY-

《MATLAB语言及应用》期末大作业报告1.数组的创建和访问(20分,每小题2分): 1)利用randn函数生成均值为1,方差为4的5*5矩阵A;实验程序:A=1+sqrt(4)*randn(5) 实验结果: A = 2)将矩阵A按列拉长得到矩阵B; 实验程序:B=A(:) 实验结果: B =

3)提取矩阵A的第2行、第3行、第2列和第4列元素组成2*2的 矩阵C; 实验程序:C=[A(2,2),A(2,4);A(3,2),A(3,4)] 实验结果: C = 4)寻找矩阵A中大于0的元素;] 实验程序:G=A(find(A>0)) 实验结果: G = 5)求矩阵A的转置矩阵D; 实验程序:D=A' 实验结果: D = 6)对矩阵A进行上下对称交换后进行左右对称交换得到矩阵E; 实验程序:E=flipud(fliplr(A)) 实验结果: E =

7)删除矩阵A的第2列和第4列得到矩阵F; 实验程序:F=A; F(:,[2,4])=[] 实验结果: F = 8)求矩阵A的特征值和特征向量; 实验程序:[Av,Ad]=eig(A) 实验结果: 特征向量Av = + - + - - + + - 特征值Ad = 0 0 0 0 0 + 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 9)求矩阵A的每一列的和值; 实验程序:lieSUM=sum(A) 实验结果: lieSUM = 10)求矩阵A的每一列的平均值; 实验程序:average=mean(A) 实验结果: average = 2.符号计算(10分,每小题5分): 1)求方程组20,0 uy vz w y z w ++=++=关于,y z的解; 实验程序:S = solve('u*y^2 + v*z+w=0', 'y+z+w=0','y,z'); y= S. y, z=S. z

MATLAB期末作业(MATLAB应用)

Matlab在汽车振动分析中的应用 XXX (昆明理工大学交通工程学院,昆明650500) 摘要:在明确汽车振动的产生原因及其危害的基础上,对汽车振动进行了理论分析、MATLAB编程计算以及试验研究。结果表明:将MATLAB强大的数据处理和可视化技术应用于汽车振动分析与控制中,既可以验证理论分析的结果,又可以预测汽车响应,具有很高的实用价值。 关键字:MATLAB 汽车振动激励阻尼自由度 1 汽车振动的产生原因及其危害 机械振动是一种特殊形式的运动,激励、质量、弹性和阻尼是振动系统的四大要素。如果把汽车作为一个系统来研究,汽车本身就是一个具有质量、弹簧和阻尼的振动系统。由于汽车内部各部分的固有频率不同,汽车在行驶中常因路面不平、车速和运动方向的变化,车轮、发动机和传动系统的不平衡,以及齿轮的冲击等各种外部和内部的激振作用而极易产生整车和局部的强烈振动。汽车的这种振动使汽车的动力性得不到充分的发挥,使经济性变坏。同时,还要影响汽车的通过性、操纵稳定性和平顺性,使乘员产生不舒服和疲乏的感觉,甚至损坏汽车的零部件和运载的货物,缩短汽车的使用寿命[1]。因此,研究汽车振动的目的主要有两方面:一是降低振动对汽车零部件的损伤、对汽车使用性能的危害;二是试图利用振动为汽车设计服务,利用振动机理设计制造振动机械以减轻劳动强度,提高工作效率是不乏先例的。 2汽车振动的理论分析 2.1建立振动的力学模型 当一个实际振动系统较复杂时,建立的模型越复杂,越接近实际情况,模拟越逼真,但往往使分析困难;相反地,建立模型时,分析越容易,但得到的结果可能不精确,因此,在建立振动系统力学模型中,总是在求得简化表达和逼真模拟二者之间的折衷[2]。振动分析的关键就是:根据研究的内容和要求,把所研究的对象以及外界对它的作用简化为一个既简单又能在动态特性方面与原来的研究对象等效的力学模型。 汽车是由多个系统组成的复杂的振动系统,每个系统都存在振动问题。主要包括发动机、传动系统、制动系统、转向系统、悬架系统、车身和车架系统存在的振动问题。研究汽车这样一个复杂的振动系统,要根据所分析的问题进行简化,具体简化方案有以下几种 [3]: 1)当汽车对称于其纵轴线时,汽车车身只有垂直振动和俯仰振动对平顺性影响最大。此时,将汽车简化成如图1a)所示的四个自由度的平面模型,因轮胎阻尼较小,在此予以忽略。在这个模型中,车身质量m2,主要考虑垂直和俯仰两个自由度前、后车轴质量m1f,m1r。有两个垂直自由度。 2)当汽车前、后轴悬架质量分配达到一定值时,前、后悬架系统的垂直振动几乎是独立的。于是可以将汽车进一步简化为如图1b)所示的车身和车轮两个自由度振动系统。 M2:为簧载(车身)质量,m1为非簧载(车轮)质量。分析平顺性时,只考虑两个质量的垂直自由度。

高等数学实验报告matlab参考答案

成都大学 高等数学 实验报告 (MATLAB版) 班级 姓名 学号 注意: 1 这个答案可由教师保存; 2 每个班级注意保存实验报告。 成都大学高等数学教研室

2011年3月 高等数学实验报告1 基本计算与作图 班级 姓名 学号 完成时间 成绩 一、实验内容 基本计算,函数的表示,函数图形的显示. 二、预期目标 1.熟悉Matlab 软件的基本操作. 2.掌握基本计算,函数的表示与函数的作图命令. 3.学会利用Matlab 软件对函数进行分析研究. 三、练习内容 习题一 1.计算下列各式的值:(写出格式及执行结果,(1)为例式) (1)16 75; >> 75^16 ans = 1.0023e+030 (2) i 31-; (3) 23sin ; >> sqrt(1-3*i) >>sin(23*pi/180) ans = 1.4426 - 1.0398i ans = 0.3907 (4)π 2 arcsin ; (5)!88. >> asin(2/pi) >> factorial(88) ans = 0.6901 ans = 1.8548e+134 2. 3 tan ,2 π==b e a e ,计算: (1)5 3 3 2 532b a ab a -+; (2))sec(arctan a .

>> a=sqrt(exp(exp(1))); b=tan(pi^2/3); >> a=sqrt(exp(exp(1))); b=tan(pi^2/3); >> 2*a^2+3*a*b^3-5*a^3*b^5 >> sec(atan(a)) ans =30.3255 ans =4.0192 3.在计算机上练习以下语句的输入:((1)为求解格式) (1)1432 1 2 -+x bx ax ; (2)1 3ln 42sin 2+-??? ?? +x x x π; >> syms a b x >> syms x >> (3*a*x^2+4*b*x^(1/2))/(x-1) >> (sin(2*x+pi/4)-log(3*x))/sqrt(x^2+1) ans =(3*a*x^2+4*b*x^(1/2))/(x-1) ans = (sin(2*x+1/4*pi)-log(3*x))/(x^2+1)^(1/2) (3)x e x x 22 )2sin (cos -. >> syms x >> (cos(x)^2-sin(2*x))*exp(2*x) ans =(cos(x)^2-sin(2*x))*exp(2*x) 习题二(只写出输入格式) 1. 作出13 y x =的图象 >> x=linspace(0,3,100); >> y=x.^(1/3); >> plot(x,y) 参见图1 2.作出14x y ?? = ???的图象 3.作出14 log y x =的图象 >> x=linspace(-2,2,50); >> fplot('log(x)/log(1/4)',[0.1,3]) >> y= (1/4).^x; >> plot(x,y) 参见图2 参见图3 图1 图2 图3

MATLAB期末大作业模版

《MATLAB》期末大作业 学院土木工程与建筑学院 专业 班级 姓名 指导教师李琳 2018 年 5 月16 日

明 作业内容题目2:问题描述:在[0 2π]范围内绘制二维曲线图y=cos(5x)*sin(x) (1)问题分析 这是一个二维绘图问题,先划定x的范围与间距,再列出y的表达式,利用plot函数绘制二维曲线。 (2)软件说明及源代码 >> x = 0:pi/10:2*pi; >>y = cos(5*x).*sin(x); >>plot(x,y) (3)实验结果 题目4:问题描述:创建符号函数并求解,要求写出步骤和运行结果 (1)创建符号函数f=ax2+bx+c (2)求f=0的解 (1)问题分析 这是一个符号函数显示以及符号函数的求解问题,第一问先定义常量与变量,在写出f表达式,利用pretty函数显示f。第二问利用solve函数求解f=0时的解。 (2)软件说明及源代码

第一问 >> syms a b c x; >> f=a*x^2+b*x+c; >> pretty(f) 第二问 >>syms a b c x; >>f=a*x^2+b*x+c; >> solve(f) (3)实验结果 1、 2、 题目5:问题描述:求积分 (1)问题分析 这是一个利用符号函数求积分的问题,先定义变量x,再列出I1表达式,利用int函数求在范围0到Pi/2上的积分。 (2)软件说明及源代码 >> syms x; >> I1=(1-2*sin(2*x))^0.5; >> int(I1,0,0.5*pi) (3)实验结果 题目6:问题描述:分别随机产生一个6×6的整数矩阵(元素可在[-20,20]之间),求该随机阵的秩,特征值和特征向量。 (1)问题分析 这是一个矩阵运算问题,先利用rand函数产生一个6*6的元素在-20到20

利用MATLAB求解微积分的方法

第 3 章 (1)M A T L A B 微积分 极限与级数的符号运算 M A T L A B 的极限与级数运算在符号系统中进行 ◆极限运算 ● l i m i t (f , x , a ) 求符号函数f 的极限 ● l i m i t (f , x , a , ’r i g h t ’) 求符号函数f 的右极限 ● l i m i t (f , x , a , ’l e f t ’) 求符号函数f 的左极限 说明:上述命令中的a 可以是无穷大 i n f 或 -i n f ?说明:多元函数的极限需要使用累次极限来计算 举例 ◆级数运算 ● s y m s u m (a n , n , i , j ) 求符号通项a n 的和 其中,当j 为无穷大i n f 时,即为无穷级数。 举例 ◆级数运算 ● t a y l o r (f , n , a , x ) 求符号函数f 在点a 关于变量x 的n -1阶泰勒多项式 举例 ● t a y l o r t o o l 泰勒工具 举例 微积分的符号运算 ◆导函数与偏导函数 ● d i f f (f , x ) 求符号函数f 对x 的一阶导函数或偏导函数 ● d i f f (f , x , n ) 求符号函数f 对x 的n 阶导函数或偏导函数 ● 注:d i f f 是d i f f e r e n t i a l (微分)的缩写 lim () x a f x + →lim () x a f x - →lim ()x a f x →j n n i a =∑

例:计算 ? 问:如何求符号函数在给定点的导数值或偏导数值? 求完导函数或偏导函数之后,使用符号替换命令 s u b s 可以求得导函数值或偏导函数值 ◆不定积分与定积分 ● i n t (f , x ) 求符号函数f 关于变量x 的不定积分 ● 注:i n t 是i n t e g r a t i o n (积分)的缩写 ● i n t (f , x , a , b ) 求符号函数f 关于变量x 的定积分,a 、b 分别是积分下限和上限,a 、b 可以是函数表达式,也可以是无穷大i n f 或-i n f 举例 ● 对于定积分,当系统求不出精确解时,如果被积函数中不含待定符号,可以使用v p a 命令给出近似解 例如: s y m s x a =i n t (s i n (s i n (x )), 1, 2) v p a (a ) ?说明: ● 参数方程求导和隐函数求导需要使用相关数学公式(见教材66-67页) ● 重积分、曲线积分与曲面积分需要使用数学方法转化为累次积分来计算 微积分的数值运算 ◆微积分的数值运算特点 采用数值算法,主要用于解决导数和定积分的近似计算问题 还可以解决离散数据的相关计算问题 ● 实例:某河床的横断面如图所示,试根据图示的测量数据(单位: m ),计算各测量点的坡度和横断面的面积。 )ln(2 22 3xy y x y x +???,)1 sin (2+x e x dx d

MATLAB期末大作业

学号:姓名: 《Matlab/Simulink在数学计算与仿真中的应用》大作业1.假设地球和火星绕太阳运转的半径分别为r和2r,利用comet指令动画显示从地球 到火星的转移轨迹(r可以任意取值,要求实时显示探测器、太阳、地球和火星的位置)。 解函数function comet(varargin) [ax,args,nargs] = axescheck(varargin{:}); error(nargchk(1,3,nargs,'struct')); % Parse the rest of the inputs if nargs < 2, x = args{1}; y = x; x = 1:length(y); end if nargs == 2, [x,y] = deal(args{:}); end if nargs < 3, p = 0.10; end if nargs == 3, [x,y,p] = deal(args{:}); end if ~isscalar(p) || ~isreal(p) || p < 0 || p >= 1 error('MATLAB:comet:InvalidP', ... 'The input ''p'' must be a real scalar between 0 and 1.'); End 指令 %particle_motion t = 0:5:16013; r1=6.7e6;%随便给定参数 %--------------------------- r2=2*r1; g=9.8; R=6.378e6; m=g*R^2; %内轨道 v_inner=sqrt(m/r1); w_inner=v_inner/r1; x_inter=r1*cos(w_inner*t); y_inter=r1*sin(w_inner*t); %外轨道 v_outer=sqrt(m/r2); w_outer=v_outer/r2;

matlab综合大作业(附详细答案)

《MATLAB语言及应用》期末大作业报告 1.数组的创建和访问(20分,每小题2分): 1)利用randn函数生成均值为1,方差为4的5*5矩阵A; 实验程序:A=1+sqrt(4)*randn(5) 实验结果: A = 0.1349 3.3818 0.6266 1.2279 1.5888 -2.3312 3.3783 2.4516 3.1335 -1.6724 1.2507 0.9247 -0.1766 1.1186 2.4286 1.5754 1.6546 5.3664 0.8087 4.2471 -1.2929 1.3493 0.7272 -0.6647 -0.3836 2)将矩阵A按列拉长得到矩阵B; 实验程序:B=A(:) 实验结果: B = 0.1349 -2.3312 1.2507 1.5754 -1.2929 3.3818 3.3783 0.9247 1.6546 1.3493 0.6266 2.4516 -0.1766 5.3664 0.7272 1.2279 3.1335 1.1186 0.8087 -0.6647 1.5888 -1.6724 2.4286 4.2471

-0.3836 3)提取矩阵A的第2行、第3行、第2列和第4列元素组成2*2的矩阵C;实验程序:C=[A(2,2),A(2,4);A(3,2),A(3,4)] 实验结果: C = 3.3783 3.1335 0.9247 1.1186 4)寻找矩阵A中大于0的元素;] 实验程序:G=A(find(A>0)) 实验结果: G = 0.1349 1.2507 1.5754 3.3818 3.3783 0.9247 1.6546 1.3493 0.6266 2.4516 5.3664 0.7272 1.2279 3.1335 1.1186 0.8087 1.5888 2.4286 4.2471 5)求矩阵A的转置矩阵D; 实验程序:D=A' 实验结果: D = 0.1349 -2.3312 1.2507 1.5754 -1.2929 3.3818 3.3783 0.9247 1.6546 1.3493 0.6266 2.4516 -0.1766 5.3664 0.7272 1.2279 3.1335 1.1186 0.8087 -0.6647 1.5888 -1.6724 2.4286 4.2471 -0.3836 6)对矩阵A进行上下对称交换后进行左右对称交换得到矩阵E; 实验程序:E=flipud(fliplr(A)) 实验结果:

Matlab期末大作业

华南农业大学 《控制系统仿真与计算机辅助设计》基于Matlab /Simulink的风力发电机仿真 施茂良200830460226 陶杰200830460227 2012年1月2日

题目: 用simulink 搭建风力发电机部分的仿真图,使其工作模式满足式(2-4),使用的发电机是永磁同步电机,具体背景材料附后。风力发电机的控制思路如下:我们需要依据风的速度控制电机的转速使得风能的利用率最高,而电机的转速通过改变永磁同步电机的定子端电压ud 和uq 来实现,具体方程为(3-28)。最终通过PWM 的导通关断时间来改变端电压,如材料图 2所示。具体要求: 1. 根据公式(2-5)画出类似 图 2.3 的曲线。 且当β=0时,画出为获得最大的风能利用率,叶尖速λ和风速v 之间的曲线关系。风力机用来捕获风能,将叶片迎风扫掠面积内的一部分空气的动能转换为有用的机械能,它决定了整个风力发电系统装置有效功率的输出。 风力机的输入功率是 3 2 3 112 2 V P A v R v ρρπ= = 式中, ρ为空气密度;A 为风力机叶片扫掠面积;R 为叶片半径。v 为风速。 风力机的输出功率为 3 012 p P A v C ρ= 式中, p C 为风能利用系数,其值小于1。 风力机输出转矩为;其中λ为叶尖速比 风能利用系数 p C 为风力机将风能转换为机械能的效率,它与风速、叶片转速,叶片直径和 桨叶节距角均有关系,是叶尖速比λ和桨叶节距角β的函数。叶尖速比λ是风能叶尖速与风速 之比,即 R v ω λ= 式中,ω为风力机叶片旋转角速度。 根据上文可知,功率与风速具有一定的关系,它们可以用下面的函数来表示

matlab大作业

图像压缩技术研究 一、离散余弦变换编码压缩图像 1. 实验源程序: I=imread('E:\MATLAB大作业\图片\cameraman.tif') I=im2double(I); %转换图像矩阵为双精度型。 T=dctmtx(8);%产生二维DCT变换矩阵 %计算二维DCT,矩阵T及其转置是DCT函数P1*X*P2的参数a1=[16 11 10 16 24 40 51 61; 12 12 14 19 26 58 60 55; 14 13 16 24 40 57 69 56; 14 17 22 29 51 87 80 62; 18 22 37 56 68 109 103 77; 24 35 55 64 81 104 113 92; 49 64 78 87 103 121 120 101; 72 92 95 98 112 100 103 99 ]; for i=1:8:200 for j=1:8:200 P=I(i:i+7,j:j+7); K=T*P*T'; I2(i:i+7,j:j+7)=K; K=K./a1;%量化

K(abs(K)<0.03)=0; I3(i:i+7,j:j+7)=K; end end figure; imshow(I2); title('DCT变换后的频域图像');%显示DCT变换后的频域图像 for i=1:8:200 for j=1:8:200 P=I3(i:i+7,j:j+7).*a1;%反量化 K=T'*P*T; I4(i:i+7,j:j+7)=K; end end figure; imshow(I4); title('复原图像'); imwrite(I4,'复原图像6.jpg'); B=blkproc(I,[8,8],'P1*x*P2',T,T'); %二值掩模,用来压缩DCT系数,只留下DCT系数中左上角的10个 mask=[1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0

MATLAB GUI课程设计期末大作业湖南理工学院汇编

《数字图像处理》期末大作业暨课程考核报告 姓名:邓巧灵 学号:24112200002 序号:02 湖南理工学院南湖学院 2014年6月

目录 一:算法设计部分 (3) 1 绘制灰度直方图,实现直方图均衡化和直方图规定化 (3) 1.1 算法原理 (3) 1.2 算法设计 (3) 1.3 实验结果及对比分析 (4) 2 灰度图像的对比度增强 (5) 2.1 算法原理 (5) 2.2 算法设计 (6) 2.3 实验结果及分析 (7) 3 图形的几何变换 (8) 3.1 算法原理 (8) 3.2 算法设计 (11) 3.3 实验结果及分析 (13) 4 图像加噪(用输入参数控制不同噪声),然后使用空域和频域进行滤波处 理 (17) 4.1 算法原理 (17) 4.2 算法设计 (19) 4.3 实验结果及分析 (20) 5 采用robert,prewitt,sobel,拉普拉斯算子对图像进行边缘提取 (23) 5.1 算法原理 (23) 5.2 算法设计 (25) 5.3 实验结果及分析 (26) 6附加题目:读入两幅图像,一幅为背景图像,一幅为含有目标的图像,应用所学的知识提取出目标 (27) 6.1 算法原理 (27) 6.2 算法设计 (27) 6.3 实验结果及分析 (28) 二、GUI界面设计部分 (29) 三小结(感受和体会) (34)

一:算法设计部分 1 绘制灰度直方图,实现直方图均衡化和直方图规定化 1.1 算法原理 (1)绘制灰度直方图 灰度值直方图定义为数字图像中各个灰度级与其出现的频率的统计关 /n,k=0,1,...,L-1且P(k)=1。统计出各个灰系,可以表示为P(k)=n k 度级的个数之后,然后在一个坐标里面绘制灰度直方图。 (2)直方图均衡化 直方图均衡化是通过对原图像进行某种灰度变换,是变换后的图像的直方图能够均匀的分布(即各个像素的灰度级均衡),这样子就能使原图像中具有相近灰度值且占有很大像素点的区域之灰度范围展宽,使大区域中的微小灰度变化显现出来。 (3)直方图规定化 使原始直方图变成某个固定的形状,从而有选择的增强某个灰度范围内的对比度。 1.2 算法设计 使用Matlab工具箱中的函数imhist(),histeq(),histeq(I,harm)分别实现直方图获取、均衡化、规定化 I=imread('trees.tif'); if (ndims(I)==3) %判断是否为灰度图像 A=rgb2gray(I);%转换为灰度图像 else A=I; end

利用MATLAB解决高等数学问题

Matlab 大作业 本人选择了利用MATLAB解决高等数学问题。 1.极限计算 limit(f,x,a):求函数f在x趋于常数a时的极限; limit(f):求函数f在x趋于0时的极限; limit(f,x,a,’right’):求函数f在x趋于常数a时的右极限;limit(f,x,a,’left’):求函数f在x趋于常数a时的左极限; 具体计算如下: 求极限M=(1-2x/n)^n(n->∞); >>syms n x; >>M=limit(‘(1-2*x/n)^n,n,inf) M= 1/exp(2*x) 相应图如下:

2.导数计算 diff(y,x,n):求y对x的n次导数; 具体计算如下: 设:y=sinax;求A=dy/dx, B=dy/da, C=d^2y/dx^2; >>syms a x; y=sin(a*x); >>A=diff(y,x) A= a*cos(a*x); >>B= diff(y,a) B= x*cos(a*x); >>C= diff(y,x,2) C= -a^2*sin(a*x) 相应图如下:

3.积分计算 int(f):直接求函数f对x的不定积分; int(f,x1,x2):求函数f在积分区间为(x1,x2)的积分值; 具体计算如下: 求I=∫(x^2+1)/(x^2-2*x+2); J=∫cosx/(sinx+cosx),x∈(0,π/2) K=e^(-x^2) x∈(0,+∞); >>syms x >>f=(x^2+1)/(x^2-2*x+2)^2; >>g=cos(x)/(sin(x)+cos(x)); >>h=exp(-x^2); I=int(f) I= (3*atan(x-1))/2+(x/2-3/2)/(x^2-2*x+2); J=int(g,0,pi/2) J= Pi/4; K=int(h,0.inf) K= Pi^(1/2)/2; 相应图如下:

相关主题
文本预览
相关文档 最新文档