Professional Documents
Culture Documents
Lab Report # 2
“Introduction to Matlab (II)”
Task -1:
Code:
x=0:pi/100:2*pi;
y1 = 2*cos(x);
y2 = cos(x);
y3 = 0.5*cos(x);
plot(x,y1)
hold on
plot(x,y2)
hold on
plot(x,y3)
xlabel('0 \leq x \leq 2\pi')
ylabel('Cosine functions')
legend('2*cos(x)','cos(x)','0.5*cos(x)')
title('Cosine plots')
axis([0 2*pi -3 3])
Graph:
Task -2:
input:: fprintf: fopen:
Task -3:
code:
clc; clear all; close all;
a=0;
b=2*pi;
n=a:0.01:b;
x1=sin(n);
x2=rand(1,length(n));
x=x1+x2
plot(n,x)
Graph: