a =
1.0000 2.0000 -1.0000 1.0000 0.8333 4.5000
>> a=[1 2 -1 1 5/6 4.5]; %qyadratic eqn coeffts with
>> b=[-1 -14 0 -6 -4 -12.15]
b =
-1.0000 -14.0000 0 -6.0000 -4.0000 -12.1500
>> c= [-2 24 -1 10 4.8 8.1]
c =
-2.0000 24.0000 -1.0000 10.0000 4.8000 8.1000
>> n= length(a)
n =
6
>> for m=1:n end solution for eqn 1
disc =
9
x1 =
2
x2 =
-1
solution for eqn 2
disc =
4
x1 =
4
x2 =
3
solution for eqn 3
disc =
-4
no real roots solution for eqn 4
disc =
-4
no real roots solution for eqn 5
disc =
0
x1 =
2.4000
x2 =
2.4000
solution for eqn 6
disc =
1.8225
x1 =
1.5000
x2 =
1.2000
>>
>> disc=zeros(1,n); x1=disc; x2=disc
x2 =
0 0 0 0 0 0
>> disc(m)
ans =
0
>> x1(m)
ans =
0
>> X=[1 3 -5 -1]';
>> A=[-2 1 00; 3 4 7 -2; 1 0 0 1; 6 7 -2 0; 5 3 1 0];
??? Error using ==> vertcat
CAT arguments dimensions are not consistent. >> A=[-2 1 0 0; 3 4 7 -2; 1 0 0 1; 6 7 -2 0; 5 3 1 0];
>> [m n]= size(A);
>> Y=zeroes(5,1);
??? Undefined function or method 'zeroes' for input arguments of type
'double'.
>> Y=zeros(5,1);
>> for k =1:m for l=1:n
Y(k)=Y(k)+A(k,l)*X(l);
end end >> Y
Y =
1 -18 0 37 9
>> disp('Expected answer is:')
Expected answer is:
>> Y1=A*X
Y1 =
1 -18 0 37 9
>> N=100;K=17;
>> n=N; found=0;
>> while found==0 if mod(n,K)==0 found=1; else n=n-1; end end >> help mod MOD Modulus after division. MOD(x,y) is x - n.*y where n = floor(x./y) if y ~= 0. If y is not an integer and the quotient x./y is within roundoff error of an integer, then n is that integer. The