Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP IN MATLAB Assume the variable NUMS is defined as a list of numbers. Write a code segment that utilizes a loop to total
PLEASE HELP IN MATLAB
Assume the variable NUMS is defined as a list of numbers. Write a code segment that utilizes a loop to total up all of the numbers in the list up to, but not including, the first positive number. Store the result in the variable NEGSUM.
% test cases % NUMS = [ -1, -4, -2, 1, 7, 9]; NEGSUM = -7; % NUMS = [ 1,-2,-3,-4]; NEGSUM = 0; % your code segment here %----------------------- % set the variable NEGSUM to be the sum of the all numbers in NUMS up to the first positive number
Notes:
- Your code must use a loop.
- You may assume that there is always a positive number in the list
- Your code must work for any valid list of numbers.
- Do not include any test cases in the code you submit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started