0% found this document useful (0 votes)
45 views3 pages

Experiment-3 Objective

The document summarizes an experiment in MATLAB that generates random vectors and computes their sums. It generates random vectors using rand() and magic(), calculates their sums along rows and columns, generates a random sequence using rand() and plots the running sum. It then generates another random sequence and calculates its running sum using a for loop.

Uploaded by

Himanshu Jangid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Experiment-3 Objective

The document summarizes an experiment in MATLAB that generates random vectors and computes their sums. It generates random vectors using rand() and magic(), calculates their sums along rows and columns, generates a random sequence using rand() and plots the running sum. It then generates another random sequence and calculates its running sum using a for loop.

Uploaded by

Himanshu Jangid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT-3

OBJECTIVE:​Generating a set of commands on a given vector to add up the values of the


elements,compute the running sum,where running sum for element c=the sum of the elements from 1
to c,generating a random sequence using rand(),magic() and plot them.

SOFTWRE USED:​MATLAB.v2012

EDITOR:

clc
clear ​all
a=10*rand(3)
a1=sum(a)
a2=sum(a,1)
a3=sum(a,2)
b=magic(3)
b1=cumsum(b)
b2=cumsum(b,1)
b3=cumsum(b,2)
c=[4 6 1 0 3 8 8]
sum=0;
for​ i=1:7
sum=sum+c(i)
end

Command window:
a = 8.1472 9.1338 2.7850

9.0579 6.3236 5.4688

1.2699 0.9754 9.5751

a1 =18.4750 16.4328 17.8289

a2 =18.4750 16.4328 17.8289

a3 = 20.0660

20.8503

11.8203

b =8 1 6

3 5 7

4 9 2

b1 =8 1 6
11 6 13

15 15 15

b2 = 8 1 6

11 6 13

15 15 15

b3 =8 9 15

3 8 15

4 13 15

c =4 6 1 0 3 8 8

sum = 4

sum =10

sum =11

sum =11

sum =14

sum =22

sum =30

OBSERVATION:
>>

SIGNATURE

You might also like