Community Profile

photo

Shubham Pandey


Last seen: nästan 4 år ago Active since 2018

Statistics

All
  • First Answer
  • Solver

View badges

Content Feed

View by

Answered
Write a function called max_sum that takes v, a row vector of numbers, and n, a positive integer as inputs. The function needs to find the n consecutive elements of v whose sum is the largest possible.
function [s,i] = max_sum(v,n) s = 0; i = 0; len = length(v); l = len-n+1; if n>len s = 0; i = -1; else for ...

ungefär 4 år ago | 2

Answered
Write a function called halfsum that takes as input an at most two-dimensional array A and computes the sum of the elements of A that are in the lower right triangular part of A
function sum = halfsum(a) sum = 0; [row,col] = size(a); for i=1:row for j=1:col if i<=j ...

ungefär 4 år ago | 0