Professional Documents
Culture Documents
ans =
7
>> x = 1+2*3
x=
7
>> 4*x
ans =
28.0000
>> t = 5;
>> t = t+1
t=
6
>> (1+2)*3
ans =
9
>> a = 5; x = 2; y = 8;
>> y = exp(-a)*sin(x)+10*sqrt(y)
y=
28.2904
>> exp(10)
ans =
2.2026e+004
>> w = [1;4;7;10;13]
w=
1
4
7
10
13
>> v = [1 4 7 10 13]
v=
1 4 7 10 13
>> w = v’
w=
1
4
7
10
13
>> v(1:3)
ans =
147
>> v(3,end)
ans =
7 10 13
>> eye(3)
ans =
100
010
001
>> c=zeros(2,3)
c=
000
>>linspace(0,10,5)
ans =
Columns 1 through 3
0 2.5000 5.0000
Columns 4 through 5
7.5000 10.0000
if delta > 0
x1 = (-b + sqrt(delta))/(2*a);
x2 = (-b - sqrt(delta))/(2*a);
fprintf('The equation has two distinct real
roots: %f and %f\n', x1, x2);
elseif delta == 0
x = -b/(2*a);
fprintf('The equation has one real root
(double root): %f\n', x);
else
%output:
Enter coefficient a:
Enter coefficient b:
Enter coefficient c:
3