Question

MATLAB Practice Problem: Write a program which calculate the total profit/year by the end of each...

MATLAB Practice Problem: Write a program which calculate the total profit/year by the end of each month in a year, given the variable P which stores profit/month for that year: P = [4 4 5 6 7 6 7 5 7 8 8 6]x1000

a) Set a loop up to calculate Ptotal(ii)=Ptotal(i-1)+P(i), to help decide about start/end conditions, use an iteration table.

b) Set up a loop to calculate Ptotal(i+1)=Ptotal(i)+P(i+1).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the logic for you. Ofcourse, both loops will achieve the same thing. If you have any further queries, just get back to me.

P = [4 4 5 6 7 6 7 5 7 8 8 6]*1000;

display (P); %Displays the monthly profit.

Ptotal = [0 0 0 0 0 0 0 0 0 0 0 0];

%a) Set a loop up to calculate Ptotal(ii)=Ptotal(i-1)+P(i), to help decide about start/end conditions, use an iteration table.

Ptotal(1) = P(1);

for i = 2:12

Ptotal(i)=Ptotal(i-1)+P(i);

end

display (Ptotal);

%b) Set up a loop to calculate Ptotal(i+1)=Ptotal(i)+P(i+1).

for i = 1:11

Ptotal(i+1) = Ptotal(i)+P(i+1);

end

Ptotal(12) = Ptotal(11)+P(12);

display(Ptotal);

Add a comment
Know the answer?
Add Answer to:
MATLAB Practice Problem: Write a program which calculate the total profit/year by the end of each...
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
  • I need this MATLAB question answered ASAP!!! thanks in advance! 10 Write a program which prompts...

    I need this MATLAB question answered ASAP!!! thanks in advance! 10 Write a program which prompts the user for data and returns the mean. The code should execute the following steps: 1) Prompts the user to enter the number of observations 2) Use a FOR-LOOP to get data from user. At each iteration, the user is asked for value of the i-th observation 3) At each iteration, print the mean of the sample up to and including the i-th observation...

  • Please complete using matlab In this problem you will utilize a for loop to compute the...

    Please complete using matlab In this problem you will utilize a for loop to compute the an approximation of the value of using the Leibniz's formula for Pi. The formula uses a summation. Follow the instructions correctly and read the questions thoroughly. 1. Set up the initial number of iteration i to obtain six iterations. 2. The approximate value of it can be given by the following formula: Approximated = Enzo 2n+1 Where n is an integer starting at zero...

  • MATLAB : Practice-4 (Oct. 31/ Nov. 1) Seat No. Name: Solve the following problems and write...

    MATLAB : Practice-4 (Oct. 31/ Nov. 1) Seat No. Name: Solve the following problems and write in the answers in blue and the plot in the box. Save the file in a pdf format and submit the answer script file and the pdf file to E-Class. 1. Re-do the Sample Problem 6-11 (Flight of a model rocket), but with the following conditions. - 16N force during the first 0.2 second - Parachute open when the downward velocity reaches 25 m/s...

  • Matlab Question 2. For this problem you have to create a program that defines two vectors...

    Matlab Question 2. For this problem you have to create a program that defines two vectors of numbers: A and B and uses a for-loop to combine the values of A and B. Note that different parts of the question below specify different orders for combining the elements. To start this exercise start a MATLAB script called q2.m and put, at the top, the vector definition: B [11:20] Question 2a: Problem definition Copy the file q2.m to q2a.m. For this...

  • calculate the company's profit or loss at the year end Problem 1-4A Listed in alphabetical order,...

    calculate the company's profit or loss at the year end Problem 1-4A Listed in alphabetical order, the following selected items (in thousands) were taken from Wildhorse Information Technology Company's December 31, 2017, financial statements: 1. Accounts payable $870 7. Rent expense 2 Accounts receivable 950 8. S. Wildhorse, capital, Jan. 1 3. Cash 3,800 9. S. Wildhorse, drawings 4. Consulting revenue 15,400 10. Salaries expense 5. Equipment 5,120 11. Utilities expense 6. Interest expense 710 $4,390 6,390 3,210 3,000 360...

  • -Create a "f(p)" MATLAB function (name it Price.m) so that it outputs the vlue of the...

    -Create a "f(p)" MATLAB function (name it Price.m) so that it outputs the vlue of the function f(P)= P2_19P+ 24/P -Create a plot of f(P) over the range $0.00 to $20.00 -Finish code by writing own Secant Method to converge on the final solution for P: %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%% % This script solves for the Equilibrium Price P, from the equation f(P)=0 % % THIS IS JUST THE INITIAL CODE FRAGMENT. YOU NEED TO COMPLETE THE SCRIPT. % *** ADD...

  • 5. Can I use logical conditions in a SWITCH statement? 6. Draw the information flow diagram...

    5. Can I use logical conditions in a SWITCH statement? 6. Draw the information flow diagram (flowchart) for a FOR loop 7. Can the looping variable in a FOR loop be a decimal number such as 2.3 ? 8. Does the looping variable in a FOR loop always have to start from 1 ? 9. Why would someone use a WHILE loop instead of a FOR loop? 10. How can I check the time elapsed to execute a set of...

  • MATLAB Required!! Write a MATLAB program named whileadder, to nput a desired maximum value. Be sure...

    MATLAB Required!! Write a MATLAB program named whileadder, to nput a desired maximum value. Be sure it is one value only Compute a running total by ones Return as output the last integer that can be added before the total exceeds max For example, if input max 60, the output should 10, because 1+2+3+4+5+6+7+8+9+10 : 55 and adding 11 would make the sum > 60M max- 55, then the output would be 10. Your Function C Reset MATLAB Documentation function...

  • MATLAB HELP This is currently what has been written. The problem is that pos needs to...

    MATLAB HELP This is currently what has been written. The problem is that pos needs to be answered in a row vector form. Currently it says pos= 1 pos=4 pos=7 pos=8 in the command window when it is run. But, I don't know how to change what is written to make it display as pos = [ 1 4 7 8] instead. How would I change the code to pos to be displayed as [ 1 4 7 8]? vec...

  • answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for...

    answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...

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