0% found this document useful (0 votes)
62 views4 pages

Matlab Experiment 3

The document summarizes an experiment conducted in a Basic Simulation Lab course. The experiment aimed to (A) add up the values in a given vector, (B) compute the running sum of a vector where the running sum at each element is the sum of elements from 1 to that element, and (C) generate a random sequence using random number functions and plot it. The document shows code snippets and outputs to check the sums and running sums of sample vectors and generate random numbers.

Uploaded by

kaushal bhagat
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)
62 views4 pages

Matlab Experiment 3

The document summarizes an experiment conducted in a Basic Simulation Lab course. The experiment aimed to (A) add up the values in a given vector, (B) compute the running sum of a vector where the running sum at each element is the sum of elements from 1 to that element, and (C) generate a random sequence using random number functions and plot it. The document shows code snippets and outputs to check the sums and running sums of sample vectors and generate random numbers.

Uploaded by

kaushal bhagat
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/ 4

LAB WORK:

Submitted by – KAUSHAL BHAGAT


Enrollment number – A35705220009
Course Code – ES204
Course name – Basic Simulation Lab
Batch – 2020-24
Submitted to – Mr.Pritam Keshari Sahoo
EXPERIMENT- 3
AIM: Generating a set of Commands on a given Vector
(Example: X = [1 8 3 9 0 1]) to (A). Add up the values of the
elements (Check with sum) (B). Compute the Running Sum
(Check with sum), where Running Sum for element j = the
sum of the elements from 1 to j, inclusive. (C) Generating a
Random Sequence using rand() / randn() functions and plot
them.

1. ADD VALUES IN A VECTOR:

>> sum = 0;
for i = 1:5
sum = sum+i;
end
display(sum)

OUTPUT
sum =
15

2. CHECK SUM:

>> A = [1 2 3 4 5]
OUTPUT
A=
1 2 3 4 5

>> B = sum(A)
OUTPUT
B=
15

3. CHECK RUNNING SUM:


>> sum = 0;
>> for i = 1:5
sum = sum+i;
display(sum)
end

OUTPUT
sum =
1
sum =
3
sum =
6
sum =
10
sum =
15

4. CHECK CUMSUM:

>> A = [1 2 3 4 5]
OUTPUT
A=
1 2 3 4 5
>> B = cumsum(A)
OUTPUT
B=
1 3 6 10 15

5. RANDOM:

>> B = rand(3)
OUTPUT
B=
0.4447 0.9218 0.4057
0.6154 0.7382 0.9355
0.7919 0.1763 0.9169

>> plot(B)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy