Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Its a Matlab question. It wants you to modify this code function y = summalleven

ID: 2079539 • Letter: I

Question

Its a Matlab question. It wants you to modify this code

function y = summalleven(n)

y=0;

for i= 2:3^n

if rem(i,2)==0

y=y+i;

end

end

Modify your Sum all even script so that given an integer n you generate a vector vec that contains all of the ODD numbers between 1 and 2^n. Then add them all up in the variable out. To solve this problem, modify the template bellow with your code. Leave the name of the function and variables unchanged. Otherwise your code will not pass the test. Click Test to test your solution before submitting it. When you are satisfied with it click Submit.

Explanation / Answer

Ans) Matlab code here

-----------------------------

function out = sumallodd(n )

%SUMALLODD Summary of this function goes here
% Detailed explanation goes here
out=0;
for i= 1:2^n
if rem(i,2)~=0 %check whether odd number
out=out+i; %if odd add them and so on
end
end

end

--------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote