Document
Document
Document
While loops)
1/ Comments:
_Explains the use of % FOR Comments
2/ Logical expressions:
2.1 Logical operations : Discusses comparison operators we have :
( == its meaning equality, < is less than, <= is less than or equal to, > its mean greater than, >= is
greater than or equal to,~= is inequality) , and logical operators (& is and logical , | its mean the
or logical, ~ its the negation logical ).
In Matlab , a logical variable can take the values 1(true) or 0(false) , for example:
>> x= 30;
>>y= 55;
ans=
ans=
A= [1,2; 3,4];
B=[1,2; 4,3];
returns 0 (false)
returns 1 (true)
4/ Summary exercise:
they are some predefined functions in Matlab describes built-in functions ( sum, prod, mean,
diag, sort ) and how to simulate them progeammatically. Foe example:
n=length(V);
sum1 =0;
for i = 1 : n
sum1=sum1+V(i)
end
disp (sum1)
5/Functions:
In computer science , a function is a reusable block of code that takes inputs and returns result.
In mathematics, a function maps each input to exactly one output.
r = number/2;
precision = 6 ;
for i = 1 : precision
r = (r+nombre . / r) / 2;
end
end
TP04 : Graphics (Management of graphics windows , plot)
Example :
>> x= [0 :1 :10]
X=
0 1 2 3 4 5 6 7 8 9 10
>> y=x.^2
Y=
0 1 4 9 16 25 36 49 64 81 100
>> plot(x,y)
3/Annotation of a Figure :
Describes adding titles, axis labels , text , annotations , and grids to graphs for better
comprehension.
F(x)=x^3 -2
>>x= -2 : 0.5 : 2 ;
>>y= x.^3-2 ;
>>plot(x,y)
For example :
>>x=[3,5,2,6]
>>y=[4,1,5,2]