Programas Matlab2
Programas Matlab2
divisor=divisor + 1;
end
if dividend ==divisor
fprintf('%d ',dividend);
count=1+count;
end
dividend =1+ dividend;
end
end
Susession de Fibonacci
n=input( ' Number of Fibonacci succession`s terms: ' )
fibonacci=zeros(1,n);
fibonacci(1)=1;
fibonacci(2)=1;
i=3;
while i <= n
fibonacci(i)= fibonacci(i-2)+ fibonacci(i-1);
i=i+1;
end
fprintf('%g ',fibonacci);
fprintf('\n');
% Read the components of a Vector and then write in the right way and in the
reverse way
display( ' Write 5 components of a vector: ' );
a=input(' fist component: ' );
b=input(' second component: ' );
c=input(' third component: ' );
d=input(' fourth component: ' );
e=input(' firth component: ' );
V=[ a b c d e ];
w=zeros(1,5);
for j=1:1:5
w(j)=V(j);
end
display( ' Vector in the right way ' );
fprintf('%g ',w);
fprintf('\n');
U=zeros(1,5);
for i= 5:-1:1
U(i)=V(6-i);
end
display( ' Vector in the opposite way ' )
fprintf('%g ',U);
fprintf('\n');
fprintf('%g ',w3);
if r1 == r2,
display( ' El area circular es 0 : ' );
else if r1 < r2
area=pi()*(r2^2-r1^2);
fprintf('%g ',area);
else
area=pi()*(r1^2-r2^2);
fprintf('%g ',area);
end
end
--------------------------------------------------------------------------------------------------------------------------
% create a program that has to write lines of * .
u=input( ' number of elements of the last line: ');
n=1;
while n<u ;
v= zeros (1,n);
v1=num2cell(v);
for i=1:n
v1{i}= ' *' ;
end
v1
n=n+1;
end
for i=1:1:n
for j=n-i:-1:0
fprintf( '*');
end
end
for w= n-i:n-1
end
for j=n-i:-1:0
fprintf( ' * ' );
end
end
break;
end
if j==lp
end
end
end
display( ' El tringulo es un equiltero con sus tres lados iguales: ');
else if a==b | b==c | c==a
display( ' El tringulo es un issceles con dos de sus tres lados iguales: ');
else
display( ' El tringulo es un escaleno con sus tres lados desiguales: ');
end
end