Question

Matlab Homework Please write a script that does the following: generates a 3 x 5 matrix...

Matlab Homework

Please write a script that does the following:

  • generates a 3 x 5 matrix of random integersand call it A.
  • generates a 3 x 3matrix of random integers and call it B.
  • "Fix" A so it can be compared to B
    • How do we "Fix" A? Make sure to reassign the value to A
  • Tell me how many elements of A are greater than or equal to B
    • This can be done in a single line. You will need to use a built in function that I have referenced but haven't extensively covered. Use the textbook, Matlab documentation, and/or the Internet for help.
    • Keep in mind what the output of a greater than comparison looks like.

This script can be done in 4 lines, not counting any header you might put on. Be sure to comment your script, these can be very simple.

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

code :

OUTPUT:

RAW_CODE :

A = randi(5,[3 5])    %generating A with random integers limit 5
B = randi(5,[3 3]) % generating B with random integers limit 5

A = A(1:size(B)(1),1:size(B)(2))    %fixing A ( means making dimensions of A same as B)

A_greater_than_equal_B_elements = nnz(A>=B)   %comparing A with B
                                                       %nnz returns nonzeros elements count

                                                      

Add a comment
Know the answer?
Add Answer to:
Matlab Homework Please write a script that does the following: generates a 3 x 5 matrix...
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
  • What an Executive Summary Is An executive summary is a specific type of document that does...

    What an Executive Summary Is An executive summary is a specific type of document that does two things: it summarizes a research article, and it offers recommendations as to how information from the article can be used. Some long reports can contain an executive summary section, as indicated in the Pearson handbook. Write a 2 pahe Executive Summary In business contexts, an executive summary is always written for a specific purpose: to explain the information in the article to a...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

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