0% found this document useful (0 votes)
36 views

Amalina Binti Salamon 2013287726 EH2225C Exercise 1

The document contains code and output from MATLAB exercises involving plotting functions of the form y = (ax^3) + (bx^2) + (cx) + d for different ranges of x values. For Exercise 1, the function plotted is y = -0.6x^2 + 2.4x + 5.5 from x = 0 to 1. Exercise 2 plots the same cubic function for different x ranges: from -2.3 to 2.7 for part (a) and from -10 to 10 for part (b).
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Amalina Binti Salamon 2013287726 EH2225C Exercise 1

The document contains code and output from MATLAB exercises involving plotting functions of the form y = (ax^3) + (bx^2) + (cx) + d for different ranges of x values. For Exercise 1, the function plotted is y = -0.6x^2 + 2.4x + 5.5 from x = 0 to 1. Exercise 2 plots the same cubic function for different x ranges: from -2.3 to 2.7 for part (a) and from -10 to 10 for part (b).
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

AMALINA BINTI SALAMON

2013287726
EH2225C
Exercise 1
>> x=[0:0.1:1]'
x=
0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000

>> y=((-0.6*(x.^2)))+2.4*x+5.5

y=

5.5000
5.7340
5.9560
6.1660
6.3640

6.5500
6.7240
6.8860
7.0360
7.1740
7.3000

>> plot(x,y)
>> xlabel('x')
>> ylabel('y')

7.4
7.2
7
6.8

6.6
6.4
6.2
6
5.8
5.6
5.4

0.1

Exercise 2(a)
x=[-2.3:0.1:2.7]'
x=

0.2

0.3

0.4

0.5
x

0.6

0.7

0.8

0.9

-2.3000
-2.2000
-2.1000
-2.0000
-1.9000
-1.8000
-1.7000
-1.6000
-1.5000
-1.4000
-1.3000
-1.2000
-1.1000
-1.0000
-0.9000
-0.8000
-0.7000
-0.6000
-0.5000
-0.4000
-0.3000
-0.2000
-0.1000
0.0000
0.1000
0.2000
0.3000

0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000
1.1000
1.2000
1.3000
1.4000
1.5000
1.6000
1.7000
1.8000
1.9000
2.0000
2.1000
2.2000
2.3000
2.4000
2.5000
2.6000
2.7000
>> y=((4*(x.^3)))-(6*(x.^2))+7*x-2.3
y=
-98.8080

-89.3320
-80.5040
-72.3000
-64.6960
-57.6680
-51.1920
-45.2440
-39.8000
-34.8360
-30.3280
-26.2520
-22.5840
-19.3000
-16.3760
-13.7880
-11.5120
-9.5240
-7.8000
-6.3160
-5.0480
-3.9720
-3.0640
-2.3000
-1.6560
-1.1080
-0.6320
-0.2040

0.2000
0.6040
1.0320
1.5080
2.0560
2.7000
3.4640
4.3720
5.4480
6.7160
8.2000
9.9240
11.9120
14.1880
16.7760
19.7000
22.9840
26.6520
30.7280
35.2360
40.2000
45.6440
51.5920

>> plot(x,y)
>> xlabel('x')
>> ylabel('y')

>> title('x versus y')

x versus y

60
40
20

0
-20
-40
-60
-80
-100
-3

2(b)
x=[-10:0.2:10]'
x=
-10.0000
-9.8000

-2

-1

0
x

-9.6000
-9.4000
-9.2000
-9.0000
-8.8000
-8.6000
-8.4000
-8.2000
-8.0000
-7.8000
-7.6000
-7.4000
-7.2000
-7.0000
-6.8000
-6.6000
-6.4000
-6.2000
-6.0000
-5.8000
-5.6000
-5.4000
-5.2000
-5.0000
-4.8000
-4.6000
-4.4000

-4.2000
-4.0000
-3.8000
-3.6000
-3.4000
-3.2000
-3.0000
-2.8000
-2.6000
-2.4000
-2.2000
-2.0000
-1.8000
-1.6000
-1.4000
-1.2000
-1.0000
-0.8000
-0.6000
-0.4000
-0.2000
0
0.2000
0.4000
0.6000
0.8000
1.0000

1.2000
1.4000
1.6000
1.8000
2.0000
2.2000
2.4000
2.6000
2.8000
3.0000
3.2000
3.4000
3.6000
3.8000
4.0000
4.2000
4.4000
4.6000
4.8000
5.0000
5.2000
5.4000
5.6000
5.8000
6.0000
6.2000
6.4000

6.6000
6.8000
7.0000
7.2000
7.4000
7.6000
7.8000
8.0000
8.2000
8.4000
8.6000
8.8000
9.0000
9.2000
9.4000
9.6000
9.8000
10.0000

>> y=((4*(x.^3)))-(6*(x.^2))+7*x-2.3
y=
1.0e+003 *
-4.6723
-4.4119
-4.1614
-3.9206
-3.6893

-3.4673
-3.2544
-3.0505
-2.8553
-2.6686
-2.4903
-2.3201
-2.1580
-2.0036
-1.8567
-1.7173
-1.5851
-1.4598
-1.3414
-1.2297
-1.1243
-1.0252
-0.9321
-0.8449
-0.7634
-0.6873
-0.6165
-0.5508
-0.4900
-0.4339
-0.3823
-0.3350

-0.2919
-0.2527
-0.2172
-0.1853
-0.1567
-0.1314
-0.1090
-0.0893
-0.0723
-0.0577
-0.0452
-0.0348
-0.0263
-0.0193
-0.0138
-0.0095
-0.0063
-0.0040
-0.0023
-0.0011
-0.0002
0.0006
0.0015
0.0027
0.0044
0.0067
0.0099

0.0142
0.0197
0.0267
0.0352
0.0456
0.0581
0.0727
0.0897
0.1094
0.1318
0.1571
0.1857
0.2176
0.2531
0.2923
0.3354
0.3827
0.4343
0.4904
0.5512
0.6169
0.6877
0.7638
0.8453
0.9325
1.0256
1.1247

1.2301
1.3418
1.4602
1.5855
1.7177
1.8571
2.0040
2.1584
2.3205
2.4907
2.6690
2.8557
3.0509
3.2548
3.4677

>> plot(x,y)
>> xlabel('x')
>> xlabel('y')
>> title('x versus y')

x versus y

4000
3000
2000
1000
0
-1000
-2000
-3000
-4000
-5000
-10

-8

-6

-4

-2

0
y

10

You might also like