Aim: Compute The Running Sum (Check With Sum), Where Running Sum For Element J Tool Used: Matlab Version 7.0.0.19920 Procedure
Aim: Compute The Running Sum (Check With Sum), Where Running Sum For Element J Tool Used: Matlab Version 7.0.0.19920 Procedure
Aim: Compute The Running Sum (Check With Sum), Where Running Sum For Element J Tool Used: Matlab Version 7.0.0.19920 Procedure
Aim: Compute the Running Sum (Check with sum), where Running Sum for element j
= the sum of the elements from 1 to j, inclusive.
Tool Used : Matlab version 7.0.0.19920
Procedure
>> sum=0
sum =
sum =
sum =
sum =
12
sum =
16
sum =
23
sum =
31
sum =
40
sum =
74
sum =
139
Aim: Generating a Random Sequence using rand() / randn() functions and plot them.
Tool Used : Matlab version 7.0.0.19920
Procedure
>> rand(5)
ans =
>> randn(5)
ans =
Aim : Evaluating a given expression and rounding it to the nearest integer value using
Round, Floor, Ceil and Fix functions
Tool Used : Matlab version 7.0.0.19920
Procedure
ciel-Rounds off to next greatest integer
floor- rounds of to previous integer
Fix-truncates the decimal value of the integer
>> round(99.8)
ans =
100
>> round(99.2)
ans =
99
>> round(-99.8)
ans =
-100
>> round(-99.2)
ans =
-99
>> ceil(99.8)
ans =
100
>> ceil(99.2)
ans =
100
>> ceil(-99.2)
ans =
-99
>> ceil(-99.8)
ans =
-99
>> floor(99.8)
ans =
99
>> floor(99.2)
ans =
99
>> floor(-99.8)
ans =
-100
>> floor(-99.2)
ans =
-100
>> fix(99.8)
ans =
99
>> fix(43.2)
ans =
43
>> fix(-43.2)
ans =
-43
Result : expressions were evaluated successfully.
EXP 4-B
Aim: Also, generating and Plots of (A)
Trigonometric Functions - sin(t),cos(t), tan(t), sec(t), cosec(t) and cot(t) for a given
duration, t.
Tool Used : Matlab version 7.0.0.19920
Procedure :
>> x=-pi:0.1:pi
x=
Columns 1 through 16
-3.1416 -3.0416 -2.9416 -2.8416 -2.7416 -2.6416 -2.5416 -2.4416 -2.3416
-2.2416 -2.1416 -2.0416 -1.9416 -1.8416 -1.7416 -1.6416
Columns 17 through 32
-1.5416 -1.4416 -1.3416 -1.2416 -1.1416 -1.0416 -0.9416 -0.8416 -0.7416
-0.6416 -0.5416 -0.4416 -0.3416 -0.2416 -0.1416 -0.0416
.
.
.
>> y=sin(x)
y=
Columns 1 through 16
-0.0000 -0.0998 -0.1987 -0.2955 -0.3894 -0.4794 -0.5646 -0.6442 -0.7174
-0.7833 -0.8415 -0.8912 -0.9320 -0.9636 -0.9854 -0.9975
Columns 17 through 32
-0.9996 -0.9917 -0.9738 -0.9463 -0.9093 -0.8632 -0.8085 -0.7457 -0.6755
-0.5985 -0.5155 -0.4274 -0.3350 -0.2392 -0.1411 -0.0416
.
.
.
>> plot(x,y)
>> y=cos(x)
y=
Columns 1 through 16
-1.0000 -0.9950 -0.9801 -0.9553 -0.9211 -0.8776 -0.8253 -0.7648 -0.6967
-0.6216 -0.5403 -0.4536 -0.3624 -0.2675 -0.1700 -0.0707
Columns 17 through 32
0.0292 0.1288 0.2272 0.3233 0.4161 0.5048 0.5885 0.6663 0.7374
0.8011 0.8569 0.9041 0.9422 0.9710 0.9900 0.9991
.
.
.
>> plot(x,y)
>> y=tan(x)
y=
Columns 1 through 16
Columns 17 through 32
>> plot(x,y)
File :sin.m
x=-pi:0.1:pi
plot(x,sin(x))
xlabel('time axis')
ylabel('sin(X)')
title('plot for sinx')
Result : vector was created successfully and graph was plotted successfully.
Exp 6
Aim : Generate a sine wave and plot using graphical enhancements
Eg: multiple plot,legend,title,lable,adding text,special symbol.color etc
Tool Used : Matlab version 7.0.0.19920
Procedure :
t=0:0.01*pi:2*pi
y=sin(t)
plot(t,y,'-r')
xlabel('x axis')
ylabel('function')
title('multiple graph')
legend('sin t')
hold on
y1=sin(3*t)
plot(t,y1,'-b')
legend('sin t','sin 3t')
eq1 =
@(x,y)((x^3-2*y)/x)
>> [x,y]=ode45(eq1,[1:0.01:3],4.2)
plot(x,y)