Discussion:: Figure 1 Plot For y Exp (-2 T) . Cos (5 T)
Discussion:: Figure 1 Plot For y Exp (-2 T) . Cos (5 T)
Discussion:: Figure 1 Plot For y Exp (-2 T) . Cos (5 T)
n=3;
p=power((1+2/(n*n)),n);
p
Output
-1.8258
n=7;
p=power ((1+2/(n*n)),n);
p
Output
1.3232
Discussion:
In this problem power function is used to solve the problem.
Code
t=[0:1:10];
y=exp(-2*t).*cos(5*t);
plot(t,y);
Output graph:-
3. Try using the WHILE and the IF statements to calculate all the Fibonacci numbers so that
the sum of two consecutive numbers is smaller than 10,000. How many are even? How many
are Odd? Try to plot them.
Code
loop=1;
a=0; b=1;c=0,odd=0,even=0;
while((a+b)<=10000)
c=a+b;
a=b;
b=c;
if rem(b,2)==0
even=even+1;
else
odd=odd+1;
end
res(loop)=b;
loop=loop+1;
end
even=even+1
odd=odd+1
x=[1:1:length(res)]
plot(x,res);
Output Graph
Output graph:-
Discussion
Here we plot the function y using plot function. The graph for is found nearly straight line
starting just above the origin.
Conclusion
In this lab we were familiarized with basic MATLAB function. We used some basic
function to plot graph of function. We were familiarized with control statement, loops,
plot function, as well as input vector matrices in MATLAB.