Exercise 1:: Solution: Code
Exercise 1:: Solution: Code
Exercise 1:: Solution: Code
Solution:
Code:
p=2.9;
a(1)=0.5;
for n=1:100
a(n+1)=p*a(n)*(1-a(n))
end
Result:
Solution:
Code:
for Tc=0:10:200
Tf=9/5*Tc+32
end
Result:
Exercise 2:
MATLAB M-file Function
Consider the following equation (𝑡)=𝑦(0)√1−𝜁𝑒−𝜁𝜔𝑛𝑡sin(𝜔𝑛√1−𝜁2∗𝑡+𝜃)
a) Write a MATLAB M-file function to obtain numerical values of y(t). Your function
must take (0), 𝜁, 𝜔𝑛, t and 𝜃 as function inputs and (𝑡) as output argument.
b) Obtain the plot for y(t) for 0<t<10 with an increment of 0.1, by considering the
following two cases
Code:
%Lab #1
%{
This program will ask users to input values for the following equation
y(t)=(y0/(sqrt(1-tao)))*exp(-tao*omegaN*t)*sin(omegaN*(sqrt(1-(tao^2))*t +
angleTeta));
%}
omegaN=input('Please enter the value of omega (in rad per second): ');
t=input('Please input the value of ''t'' to evaluate the function y(t): ');
y_t=(y0/(sqrt(1-tao)))*exp(-tao*omegaN*t)*sin(omegaN*(sqrt(1-(tao^2))*t +
angleTeta));
disp(y_t);
The above output demonstrate that Mat Lab can be use to obtain numerical values of
an equation such as (𝑡)=𝑦(0)√1−𝜁𝑒−𝜁𝜔𝑛𝑡sin(𝜔𝑛√1−𝜁2∗𝑡+𝜃)
Evaluated at the users specified values.
y(t) = 𝑦(0)√1−𝜁𝑒−𝜁𝜔𝑛𝑡sin(𝜔𝑛√1−𝜁2∗𝑡+𝜃)
Exercise 4:
Plot the function
Y(x)=exp(-x)sin(8x) for 0<=x<=2π
Solution:
Code:
Function y = func(x) % function decleration
Y=exp(-x)*sin(8*x);
Command window .
I=1;
X=0;
While(x<=(2*pi))
Y(i)=func(x);
I=i+1;
X=x+0.1;
End
Plot(y)
Screen shots:
Graph plot screenshot: