码迷,mamicode.com
首页 > 其他好文 > 详细

MATLAB实验

时间:2017-06-22 20:13:00      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:width   2.0   top   sign   efi   2.7   实验目的   label   on()   

数据处理

实验目的

进一步熟悉MATLAB数据处理基本功能。

实验内容

成绩评估

 

姓名

课1

课2

课3

课4

课5

总分

平均

标准差

优良率

学生1

97

86

89

94

96

462

92.4

4.7223

1

学生2

70

94

87

79

60

390

78

13.472

0.4

学生3

66

60

73

92

71

362

72.4

12.054

0.2

学生4

94

65

66

78

61

394

72.8

13.442

0.2

学生5

69

92

66

78

87

392

78.4

11.194

0.4

学生6

85

77

67

78

86

393

78.6

7.6354

0.4

学生7

98

95

76

76

99

444

88.8

11.777

0.6

总分

579

569

524

575

560

 

 

 

 

平均

82.714

81.286

74.857

82.143

80

 

 

 

 

标准差

579

569

524

575

560

 

 

 

 

优良率

0.57

0.57

0.28

0.28

0.57

 

 

 

 

 
score=fix(rand(7,5)*40+60);

sunmlie=sum(score);

sumhang=sum(score‘);

meanlie=mean(score);

meanhang=mean(score‘);

a=meanhang‘;

stdlie=std(score);

stdhang=std(score‘);

youliang=score>=80;

youlianghang=sum(youliang‘)/5;

youlianglie=sum(youliang)/7;

曲线作图

做出如下曲线,sin(x),sin(3x),sin(x)+sin(3x),x2,x3,1/x,log2(x),log10(x).

含多曲线合成图,多子图合成图,用title命令,label命令,axis命令对图形进行规范化。

 C++代码

 1 // Simulation.h: interface for the CSimulation class.
 2 //
 3 //////////////////////////////////////////////////////////////////////
 4 
 5 #if !defined(SIMULATION_H)
 6 #define SIMULATION_H
 7 
 8 #include <vector>
 9 #include "Rocket.h"
10 #include "Spark.h"
11 using namespace std;
12 
13 class CSimulation  
14 {
15 public:
16 //Member functions:
17     //Constructor
18     CSimulation();
19     //Deconstructor
20     virtual ~CSimulation();
21     //Display all the particles
22     void Display();
23     //Calculate total number of particles
24     int GetParticleNum();
25     //One Euler step of the simulation
26     void EulerStep();
27     //When a rocket reaches its top height, it explodes and calls this function to generate sparks
28     void Explode(float posx, float posy, float RocketSpeed, float* color);
29     //When a key is pressed, Simulation calls this function to generate a rocket
30     void FireRocket(float pos, float* color);
31     //Set the speed of the wind
32     void SetWindSpeed(float windSpeedValue);
33     //Set Total Explosions
34     void SetTotalExplosions(int explosions);
35     
36 //Member variables:
37     //Vector of CRocket. Rockets in this vector are either still flying or generating sparks
38     vector<CRocket*> rockets;
39     //Vector of CSpark.
40     vector<CSpark*> sparks;
41     //Delta time for a Euler step.
42     float deltaT;
43     //Velocity of the wind in x direction
44     float windSpeed;
45     unsigned int totalExplosions;
46 };
47 
48 #endif // !defined(SIMULATION_H)

 

 

 

代码:

t=0:100;

y1=sin(t);

y2=sin(3*t);

y3=sin(t)+sin(3*t);

y4=t.^2;

y5=t.^3;

y6=t.^-1;

y7=log2(t);

y8=log10(t);

subplot(1,1,1),plot(t,y1,‘r‘);hold on;plot(t,y2,‘g‘);hold on;plot(t,y3,‘b‘);legend(‘sin(t)‘,‘sin(3t)‘,‘sin(t)+sin(3t)‘);title(‘y1/y2/y3‘);xlabel(‘t‘);ylabel(‘y‘);axis([0 20 -2 2]);grid on;

figure(4);

subplot(1,1,1),plot(t,y4,‘r‘);hold on;plot(t,y5,‘g‘);legend(‘t^2‘,‘t^3‘);title(‘y4/y5‘);xlabel(‘t‘);ylabel(‘y‘);

figure(3);

subplot(1,1,1),plot(t,y6,‘b‘);legend(‘1/t‘);title(‘y6‘);xlabel(‘t‘);ylabel(‘y‘);

figure(2);

subplot(1,1,1),plot(t,y7,‘r‘);hold on;plot(t,y8,‘g‘);legend(‘log2(t)‘,‘log10(t)‘);title(‘y7/y8‘);xlabel(‘t‘);ylabel(‘y‘);

figure(1);

  

MATLAB实验

标签:width   2.0   top   sign   efi   2.7   实验目的   label   on()   

原文地址:http://www.cnblogs.com/fylr/p/7066910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!