0% found this document useful (0 votes)
32 views7 pages

Function: (Y) FCT (X) y 3 X. 2+2 X Plot (X, Y)

Uploaded by

Med
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views7 pages

Function: (Y) FCT (X) y 3 X. 2+2 X Plot (X, Y)

Uploaded by

Med
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

function[y] = fct(x)

y= 3*x.^2+2*x
plot(x,y)

x=0;0.5;5

ans =

>> y=fct(x)

Undefined function 'fct' for input arguments of type 'double'.

Did you mean:

>>fct
Error using fct (line 2)

Not enough input arguments.

>> y=fct(x)

y=

y=

>> x=0:0.5:5

x=

Columns 1 through 9

0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000

Columns 10 through 11

4.5000 5.0000

>> y=fct(x)

y=

Columns 1 through 9
0 1.7500 5.0000 9.7500 16.0000 23.7500 33.0000 43.7500 56.0000

Columns 10 through 11

69.7500 85.0000

y=

Columns 1 through 9

0 1.7500 5.0000 9.7500 16.0000 23.7500 33.0000 43.7500 56.0000

Columns 10 through 11

69.7500 85.0000

>>

>> a=1

a=

>> b=2

b=

2
>> f=inline ('3*x^2+2*x')

f=

Inline function:

f(x) = 3*x^2+2*x

>>

>>

>>

>>

>> f=inline ('3*x^2+2*x')

f=

Inlinefunction:

f(x) = 3*x^2+2*x
functionIpm=point_milieu (a,b,f)
Ipm(f)= (b-a)f(a+b/2)
end

application :
functionIpm=point_milieu (a,b,f)
Ipm= (b-a)*f((a+b)/2)
End

1) a=1
2)
3) a =
4)
5) 1
6)
7) >> b=2
8)
9) b =
10)
11) 2
12)
13) >> f= inline('3*x^2+2*x)
14) f= inline('3*x^2+2*x)
15) |
16) Error: String is not terminated properly.
17)
18) >> f= inline('3*x^2+2*x)
19) f= inline('3*x^2+2*x)
20) |
21) Error: String is not terminated properly.
22)
23) >> f= inline('3*x^2+2*x')
24)
25) f =
26)
27) Inlinefunction:
28) f(x) = 3*x^2+2*x
29)
30) >>Ipm=point_milieu (a,b,f)
31)
32) Ipm =
33)
34) 9.7500
35)
36)
37) Ipm =
38)
39) 9.7500

2)

function[Ipmc]=point_milieu_composite(a,b,f,n)
h=(b-a)/n;
Ipmc=0;
x=a:h:b;
for j=1:n
xb=(x(j)+x(j+1))/2;
Ipmc=h*f(xb)+Ipmc;
end

a=1

a =

>> b=2

b =
2

>> f=inline('3*x^2+2*x')

f =

Inline function:
f(x) = 3*x^2+2*x

>> n=4

n =

>> [Ipmc]=point_milieu_composite(a,b,f,n)

Ipmc =

9.9844

4)

function[It]=trapeze(a,b,n,f)
h=(b-a)/n;
It=0;
x=a:h:b;
for j=1:n
It=h/2*(f((xj))+f((xj+1)))+It;

end
>> f=inline('3*x^2+2*x')

f =

Inline function:
f(x) = 3*x^2+2*x

>> n=4

n =

>> [It]= trapeze (a,b,f,n)

You might also like