You are on page 1of 10

x = 0 : pi/100 : 2*pi;

y = sin(x);
plot(x,y);
xlabel('x-axis');
ylabel('y-axis');
title('plot of the sine wave');

plot of the sine wave


1

0.8

0.6

0.4

0.2
y-axix

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7
x-axix
t = 0:pi/100:2*pi;
y1=sin(t);
y2=sin(t+pi/2);
plot(t,y1,t,y2)
%grid on;
x = -pi:pi/20:pi; 1

plot(sin(x)) 0.8

0.6
hold on 0.4

plot(cos(x)) 0.2

hold off 0

-0.2
%grid on -0.4

-0.6

-0.8

-1
0 5 10 15 20 25 30 35 40 45
plot of a
t = 0 : 0.1 : 5; 10

a = 10 * exp(-t); 9

plot(t,a); 8

7
xlabel('time in sec'); 6
ylabel('output');

output
5

title('plot of a'); 4

grid on; 3

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time in sec
x = 0 : 0.5 : 10 35

y = 3 * x + 5;
30
plot(x,y);
%---- 25
gtext('its a straight line');
grid on;
output
20

xlabel('time');
ylabel('output'); 15

10

5
0 1 2 3 4 5 6 7 8 9 10
its a straight line
time
8

x1 = 0 : 0.01 : 20; 4

y1 = exp(0.1*x1).*sin(x1); 2

y1 axix
plot(x1,y1); 0

% grid on; -2

xlabel('x1 axix'); -4

ylabel('y1 axix'); -6
0 2 4 6 8 10 12 14 16 18 20
x1 axix
20

x = -5 : 0.1 : 10; 18
y = 3* x.^2 + 2 *x + 5; 16
plot(x,y); 14
% axix change
12
axis([-5 5 0 20]);

y axis
10
xlabel('x axis');
8
ylabel('y axis');
6

0
-5 -4 -3 -2 -1 0 1 2 3 4 5
x axis
close all;
clear;
x1 = input('Enter the sequence = ');
reply = input('Would you like to see an echo? (yes/no): ', 's');
if strcmp(reply,'yes')
disp(x1);
elseif strcmp(reply,'no')
disp('ok');
else
disp('no match');
end
A) Write a program to Print Hello world n times
for n=0:5
disp('Hello World');
end

SOLUTION
The code 0:5 creates a vector of integers starting at 0 and going to 5; this vector has 6 elements. "Hello World" will be
printed once for each element in the vector (6 times).

Write a program to display n number?????


B) n =input('Enter any number = ');
for j = 1:n
n = n-1;
disp(j);
end
Write a program to display value of I,s when i<3???

clear all;
s = 0;
i=0;
while i < 3
s=s+i
i=i+1
% use terminator
end

You might also like