Question

Write a MATLAB code which will show which elements of A are more than B and their indices.


2. A=[17 18 12 15 20 22 25 26 28 29 30 21] and B=[11 20 25 28 29 13 14 25 22 33 10 23] 


Write a MATLAB code which will show which elements of A are more than B and their indices.

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

Here is the code:

A = [17 18 12 15 20 22 25 26 28 29 30 21];
B = [11 20 25 28 29 13 14 25 22 33 10 23];
for i=1:12 %loop over each array
if A(i) > B(i) %compare the values
display([A(i),i]); %display if A is greater than B
end
end

Here is a screenshot for indentation:

A = [17 18 12 15 20 22 25 26 28 29 30 21]; B = [11 20 25 28 29 13 14 25 22 33 10 231; for i=1:12 %loop over each array if A(i

Here is the screenshot of the output:

1587602278953_image.png

Comment in case of any doubts.

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB code which will show which elements of A are more than B and their indices.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twent...

    A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twenty transactions for each agent were selected at random and the time lapse (in days) for handling each transaction was determined. The results follow: Agent 1 Agent 2 Agent 3 Agent 4 Agent 5 24 18 10 15 33 24 20 11 13 22 29 20 8 18 28 20 24...

  • In Matlab The arrays price A, price B and price C given below contain the price...

    In Matlab The arrays price A, price B and price C given below contain the price in dollars of the three stocks over 10 days. price A = [19, 18, 22, 21, 25, 19, 17, 21, 27, 29] price B = [22, 17, 23, 24, 18, 16, 25, 28, 27, 27] price C = [10, 11, 12, 13, 19, 17, 20, 21, 24, 28] For the stock data, write a MATLAB code to plot the stock price vs. days graph...

  • Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine...

    Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....

  • write the jave code for the following 1 2 7 B9 4 5 10 11 12...

    write the jave code for the following 1 2 7 B9 4 5 10 11 12 15 13 16 23 24 14 22 17 25 26 18 19 21 20 INRerscrorTro zo Question 11 15 points Save Answer Suppose we have the following code in a Java program: int numbers- (23, 2, 32, 13, 43, 67, 102, 19, 5, 88) System.out.printin ("Please enter a number: ") Scanner console - new Scanner (System.in): int numEntered - console.nextInt (): Add additional lines...

  • A doctor discovers a particular disease and determines the life expectancy is not good. He gathers...

    A doctor discovers a particular disease and determines the life expectancy is not good. He gathers the data for his patents and posts it in the table below. The claims that the average life expectancy once the disease presents itself is less than 15 days. Check his claim and make an appropriate report about your findings Patient Days till passing Days -Patient # 1-24 2 -23 3 -13 4 -20 5 -10 6 -18 7 -13 8 -14 9 -24...

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays...

    Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature. Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages. Here is the data file (below). 1. 14 25 2. 12...

  • After discussing the issue with you and others in the Finance department, the manager decided to...

    After discussing the issue with you and others in the Finance department, the manager decided to change the payment terms for Accounts Receivable. The payment time remained at 14 days, but the penalty for late payments was increased. After about 3 months under the new payment terms, you asked the manager to collect a second stratified random sample. The data is presented in the second column of the worksheet (see the tab titled, “Data – Case #2) under the Heading...

  • Game   Point_Differential   Assists   Rebounds   Turnovers   Personal_Fouls 1   15   15   38   11   9 2   36   20   43 &

    Game   Point_Differential   Assists   Rebounds   Turnovers   Personal_Fouls 1   15   15   38   11   9 2   36   20   43   8   13 3   16   21   29   7   13 4   45   22   46   11   11 5   12   11   40   7   22 6   -10   10   31   13   26 7   11   19   45   11   7 8   12   16   32   16   14 9   3   16   27   18   15 10   19   9   34   17   17 11   40   16   41   9   17 12   44   12   29   9   22 13   16  ...

  • 10. (12 points) The arrays price A, price B and price C given below contain the...

    10. (12 points) The arrays price A, price B and price C given below contain the price in dollars of the three stocks over 10 days. price A = [19, 18, 22, 21, 25, 19, 17, 21, 27, 29] price B = [22, 17, 23, 24, 18, 16, 25, 28, 27, 27] price C = [10, 11, 12, 13, 19, 17, 20, 21, 24, 28] For the stock data, write a MATLAB code to plot the stock price vs. days...

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