Professional Documents
Culture Documents
B.Tech CSE
3CSE-4X
Apparatus:
https://octave-online.net, GNU Octave
Theory:
If A is a vector, sum(A) returns the sum of the elements. If A is a matrix, sum(A) treats the columns of A as
vectors, returning a row vector of the sums of each column.
If A is a vector, then cumsum(A) returns a vector containing the cumulative sum of the elements of A.
If A is a matrix, then cumsum(A) returns a matrix containing the cumulative sums for each column of A.
Program:
clear all
clc
close all
%Sum
X = [ 1 8 3 9 0 1]
B = sum(X)
%running sum
totsum = 0
for i = 1:5
totsum += X(i);
i = i + 1;
totsum
end
E = cumsum(X)
F = cumsum (X,2)
G = cumsum ( X, 1)
R1= rand(4,5)
R2= randi(4,6)
%Plot
figure('name', "Figure of R1");
plot(R1);
title('graph of R1');
grid on;