USING MATLB
PLEASE SHOW commands and output.
QUESTION 1. Create a function sumcomp that compares the sum of all the odd-indexed elements with the sum of all the even-indexed elements and returns:
0, if they are equal,
1, if the sum of the odd-indexed elements is greater,
2, if the sum of the even-indexed elements is greater
function result = sumcomp(lst)
oddSum = 0;
evenSum =0;
result =0;
for i=1:length(lst)
if(mod(i,2) == 0)
evenSum = evenSum + lst(i);
else
oddSum = oddSum + lst(i);
end
end
if(oddSum == evenSum)
result = 0;
elseif(oddSum > evenSum)
result = 1;
else
result = 2;
end
end


USING MATLB PLEASE SHOW commands and output. QUESTION 1. Create a function sumcomp that compares the...
need question 3 assap using cin and cout outputs please
Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Display both arrays x and y in a table with labeled column headings. 0 y- 2x+1 2) 120 pts] Consider the following 2D array. 01 2 -1 X-3 5 0 6 -3 7 -15 Use the standard notation and obtain the following (a) Create and display array...
Question 5. Design an optimized circuit for the function output that compares 2-bit numbers (A and B) and detects A is greater than B. (Hint: Truth table, Boolean function, gate implementation)
Question 5. Design an optimized circuit for the function output that compares 2-bit numbers (A and B) and detects A is greater than B. (Hint: Truth table, Boolean function, gate implementation)
Please answer all the questions
Here is evenodd function:
function [xe, xo, m] = evenodd(x,n)
% Real signal decomposition into even and odd parts
% -------------------------------------------------
% [xe, xo, m] = evenodd(x,n)
%
if any(imag(x) ~= 0)
error('x is not a real sequence')
end
m = -fliplr(n);
m1 = min([m,n]); m2 = max([m,n]); m = m1:m2;
nm = n(1)-m(1); n1 = 1:length(n);
x1 = zeros(1,length(m));
x1(n1+nm) = x; x = x1;
xe = 0.5*(x + fliplr(x));
xo = 0.5*(x -...
Compute the following problems using Math
Lab.
Instructions: Answer All Questions using MATLAB commands. Question 1. Create a vector of the even whole numbers between 31 and 75. Question 2. Let x [2516] a. Add 16 to each element b. Add 3 to just the odd-index elcments c. Compute the square root of each element d. Compute the square of each element Question 3. Let x 13 268T and y [4 1 3 5] (NB. x and y should be...
Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 - 1000. You will pass the array into functions that will perform operations on the array. Function 1: Create a function that will output all the integers in the array. (Make sure output is clearly formatted. Function 2: Create a Function that will sum and output all the odd numbers in the array. Function 3: Create a Function that will sum and output all the...
PLEASE SOLVE USING BASIC C++ CODEING PRINCIPLES
PLEASE USE BASIC ARRAY, FUNCTION, AND LOOPING PRINCIPLES
PLEASE COMPLETE ALL ASPECTS OF PAPER
THANK YOU!!!
Objectives To learn to code, compile and run a program containing ARRAYS. . Assignment Plan and code a modular program utilizing arrays. Use at least three functions to solve the problem. Input numbers from a textfile. Input the numbers, one by one. Store the even numbers in one array. Store the odd numbers in a second array....
Write a program that finds (ANSWER IN C LANGUAGE!): 1. The sum of all elements at even subscripts 2. The sum of all elements at odd subscripts 3. The sum of all elements You are allowed to perform this functionality within main. Main program: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <stdio.h> int main() { /* Declare array variables */ const int NUM_VALS = 4; int userValues[NUM_VALS]; int i; // counter int even = 0; int odd = 0; int sum = 0; /* Initialize...
PLEASE WRITE IN C# Problem: Summing up sums. For this question, you’ll understand the importance of using the results of smaller sets of work. You’re going to create a recursive function that takes in an array of random integers and returns a “sum of sums”. This is best explained through an example. If you have 5 elements in an array, the function should return the sum of elements 0-4, 1-4, 2-4, 3-4, and 4. So, if we had an array...
Create a function in JavaScript called "sum" that takes in an array as a parameter and returns the sum of all of the EVEN numbers in a given array. Please note: the array passed in can have any data type, i.e. Strings, Numbers, Booleans, undefined, etc. HINT: the expression typeof will help discern var types. For example if I have: var x = 4, and I do typeof(x) - the output would be "Number" Example run: sum([1, 4, 8, 10,...