Question

Use MATHLAB to answer the following question. Post your full working code and a screenshot of the output!

1. Write a function sumsteps2 that calculates and returns the sum of 1 to n in steps of 2, where n is an argument passed to t

0 0
Add a comment Improve this question Transcribed image text
Answer #1
function s = sumstep2(n)
    s=0;
    for x=1:2:n
        s=s+x;
    end
end

Output:

octave:2> sumstep2 (11) ans = 36

Add a comment
Know the answer?
Add Answer to:
Use MATHLAB to answer the following question. Post your full working code and a screenshot of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please paste your code and a screenshot of your output! 1. An integer n is divisible...

    Please paste your code and a screenshot of your output! 1. An integer n is divisible by 9 if the sum of its digits is divisible by 9. Develop a program to determine whether or not the following numbers are divisible by 9: n= 154368 n 621594 n-123456 2. A number is said to be perfect if the sum of its divisors (except for itself) is equal to itself. For example, 6 is a perfect number because the sum of...

  • Code the following example and screenshot the text output. After you have the test code working,...

    Code the following example and screenshot the text output. After you have the test code working, modify it so that it has the following features: ○ The ‘while’ loop is inside a try/except error check. This allows a <CTRL>C to break out of the loop ○ Keep track of the number of button presses with an accumulator variable ○ After the loop is ended with an exception, create an attractive output which tells the user that the program has ended...

  • In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand....

    In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task.                                                                                                           Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop                                                                                              int cnt = 1;     do {     cnt += 3;     } while (cnt < 25);     cout << cnt; It runs ________ times    ...

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    Can you send the code and the screenshot of it running? 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...

  • mathlab please copy and paste the code and output Q1. (50 points) Consider the following mathematical...

    mathlab please copy and paste the code and output Q1. (50 points) Consider the following mathematical sequence for any mumber fathe sequence, the first number is 1 = 0. The remaining terms are computed via the following method. The second number of the sequence is given by 1 /2 f iseve Ty - 3x + 1 if, is add The third number of the sequence is given by 1 /2 fils even 133ry + 1 ifr, is odd Thus, the...

  • This basic problem demonstrates the while-loop. (USE MATLAB) Write a Matlab function called steps that takes one scalar...

    This basic problem demonstrates the while-loop. (USE MATLAB) Write a Matlab function called steps that takes one scalar as an input argument and returns two scalars as output arguments. If it is called this way [n, d_left] = steps(d), then it sets n equal to the minimum number of steps required to move from a distance of one foot away from a wall to a distance less than d feet from the wall. The first step is 1/2 foot. If...

  • Write a python program (recursive.py) that contains a main() function. The main() should test the following...

    Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...

  • Answer in python 3 and can you please include a screenshot of the code and the...

    Answer in python 3 and can you please include a screenshot of the code and the output Problem 4 (Quicksort) For this problem you must implement the recursive quicksort algorithm covered in lecture to sort points based on their distance from the point (0, 0). Crete a Python file called quicksort.py and implement a function called quicksort(list) that does the following: COMP 1005/1405A – S19 – A5 Due Saturday, June 15th at 11:59 PM 3 1. Takes a 2D list...

  • CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT...

    CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT ALLOWED) Write a function that accepts an array as argument. The function should loop through the array elements and accumulate the sum of ASCII value of each character in element and return the total. For example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum of 65 + 98 + 99 + 49 + 50 Write a function that accepts two arguments (a...

  • Exercises (No programming is required. Your submission should be a word or pdf document.) Question 1:...

    Exercises (No programming is required. Your submission should be a word or pdf document.) Question 1: (3 Marks) Convert from binary the number (11081181), to decimal and show all steps. Question 2: (3 Marks) Convert from decimal (350)e to binary and show all steps Question 3: (3 Marks) Convert from decimal (3567)s to hexadecimal and show all steps. Question 4: (3 Marks) Convert from hexadecimal (45AC)s to octal and show all steps Question 5: (2 Marks) Given the following snippet...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT