1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bogdanovich [222]
3 years ago
13

Consider the following arrays. 1 4 21 2 4 100 B # 111(A) L3π 42 Write MATLAB expressions to do the tollowing a. Select just the

second row of B. b. Evaluate the sum of the second row of B. c. Multiply the second column of B and the first column of A element by element. d. Evaluate the maximum value in the vector resulting from element-by- element multiplication of the second column of B with the first column of A. e. Use element-by-element division to divide the first row of A by the first three elements of the third column of B. Evaluate the sum of the elements of the resulting vector
Computers and Technology
1 answer:
andriy [413]3 years ago
6 0

Answer:

Complete Matalb code along with explanation and output results are given below

Explanation:

We are given following two matrices A and B of size 4x3

A = [1 4 2; 2 4 100; 7 9 7; 3 pi 42]

B = log(A)

(a) Select just the second row of B

% to extract any row use this syntax  B(row no, : )  we can also extract more than 1 row or any particular elements in a specific row

B_row_2 = B(2,:)

(b) Evaluate the sum of the second row of B

% simply use the sum function and pass it any vector or matrix and it will return their sum

sum_B_row_2 = sum( B_row_2(:) )  

(c) Multiply the second column of B and the first column of A element by element

% first we extract the column 2 of matrix B and column 1 of matrix A. use this syntax  B( : ,col no ) to extract any column  

B_col_2 = B(:,2)

A_col_1 = A(:,1)

% Then we use ( .*) to multiply element by element. To use standard multiplication of matrices only use asterisk sign without coma

multiply=B_col_2.*A_col_1

(d) Evaluate the maximum value in the vector resulting from element-by- element multiplication of the second column of B with the first column of A

% we can find the maximum value in a vector or matrix by using max function so we pass the multiply variable where our result was stored

max_value = max(multiply)

(e) Use element-by-element division to divide the first row of A by the first three elements of the third column of B. Evaluate the sum of the elements of the resulting vector

%  First we extract the row 1 of matrix A

A_row_1 = A(1,:)

%  Then we extract the column 3 of matrix B

B_col_3 = B(:,3)

%  Then we extract the first 3 elements of column 3 of matrix B

B_col_3 = B_col_3(1:3)

% Finally we use ( ./ ) to use element by element division

divide = A_row_1./B_col_3

% Using the sum function again results in the addition of entire elements of resultant matrix

sum_divide = sum( divide(:) )

Only Code:

A = [1 4 2; 2 4 100; 7 9 7; 3 pi 42]

B = log(A)

B_row_2 = B(2,:)

sum_B_row_2 = sum( B_row_2(:) )  

B_col_2 = B(:,2)

A_col_1 = A(:,1)

multiply=B_col_2.*A_col_1

max_value = max(multiply)

A_row_1 = A(1,:)

B_col_3 = B(:,3)

B_col_3 = B_col_3(1:3)

divide = A_row_1./B_col_3

sum_divide = sum( divide(:) )

Output Results:

A =

    1.0000     4.0000     2.0000

    2.0000     4.0000   100.0000

    7.0000     9.0000     7.0000

    3.0000     3.1416    42.0000

B =  

  0.00000   1.38629   0.69315

  0.69315   1.38629   4.60517

  1.94591   2.19722   1.94591

  1.09861   1.14473   3.73767

B_row_2 =   0.69315   1.38629   4.60517

sum_B_row_2 =  6.6846

B_col_2 =  

  1.3863

  1.3863

  2.1972

  1.1447

A_col_1 =

  1

  2

  7

  3

multiply =

   1.3863

   2.7726

  15.3806

   3.4342

max_value =  15.381

A_row_1 =     1   4   2

B_col_3 =  

  0.69315

  4.60517

  1.94591

  3.73767

B_col_3 =

  0.69315

  4.60517

  1.94591

divide =

  1.44270   5.77078   2.88539

  0.21715   0.86859   0.43429

  0.51390   2.05559   1.02780

sum_divide =  15.216

You might be interested in
I need help with completing this python code.Complete the Car class by creating an attribute purchase_price (type int) and the m
netineya [11]

Answer:

class Car:

   def __init__(self):

       self.model_year = 0

       # TODO: Declare purchase_price attribute

       self.purchase_price = 0

       self.current_value = 0

   def calc_current_value(self, current_year):

       depreciation_rate = 0.15

       # Car depreciation formula

       car_age = current_year - self.model_year

       self.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)

# TODO: Define print_info() method to output model_year, purchase_price, and current_value

   def print_info(self):

       print("Model year: ",self.model_year)

       print("Purchase year: ",self.purchase_price)

       print("Current value: ",self.current_value)

def main():

   year = int(input())

   price = int(input())

   current_year = int(input())

   my_car = Car()

   my_car.model_year = year

   my_car.purchase_price = price

   my_car.calc_current_value(current_year)

   my_car.print_info()

if __name__ == "__main__":

   main()

Explanation:

The Car class in the python program is used to create a car object instance with class methods model_year, purchase_price, and calc_current_value, which accepts as arguments, year, price and current_year respectively. The main function runs if only the python module is run and interpreted to print out the year and current price of a car object instance defined.

4 0
3 years ago
Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a con
Sophie [7]

Answer:

Explanation:

The following code is written in Java. It creates the three classes as requested with the correct constructors, and getter/setter methods. Then the test class asks the user for all the information and creates the customer object, finally printing out that information from the object getter methods.

import java.util.Scanner;

class Person {

   String name, address, telephone;

   private void Person (String name, String address, String telephone) {

       this.name = name;

       this.address = address;

       this.telephone = telephone;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public String getTelephone() {

       return telephone;

   }

   public void setTelephone(String telephone) {

       this.telephone = telephone;

   }

}

class Customer extends Person {

   String customerNumber;

   Boolean mailingList;

   public Customer(String s, Boolean mail) {

       super();

       this.customerNumber = customerNumber;

       this.mailingList = mailingList;

   }

   public String getCustomerNumber() {

       return customerNumber;

   }

   public void setCustomerNumber(String customerNumber) {

       this.customerNumber = customerNumber;

   }

   public Boolean getMailingList() {

       return mailingList;

   }

   public void setMailingList(Boolean mailingList) {

       this.mailingList = mailingList;

   }

}

class Test {

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Customer Name: ");

       String name = in.nextLine();

       System.out.println("Enter Customer Address: ");

       String address = in.nextLine();

       System.out.println("Enter Customer Telephone: ");

       String telephone = in.nextLine();

       System.out.println("Would you like to receive mail? y/n ");

       Boolean mail;

       if(in.nextLine() == "y") {

           mail = true;

       } else {

           mail = false;

       }

       Customer customer = new Customer("1", mail);

       customer.setName(name);

       customer.setAddress(address);

       customer.setTelephone(telephone);

       System.out.println("Name: " + customer.getName());

       System.out.println("Address: " + customer.getAddress());

       System.out.println("Telephone: " + customer.getTelephone());

       System.out.println("Wants to receive mail: " + String.valueOf(customer.getMailingList()));

   }

}

7 0
3 years ago
In order to protect your computer from the newest virus, which of the following should you do after you've installed a virscan s
NNADVOKAT [17]
After installing your anti-virus, you must do the following to make sure that your computer will be virus free moving forward:

1. Scan every drive of your computer.
2. Scan every program, photo, video, etc before opening those.
3. Avoid visiting restricted sites.
4. Update your antivirus application. This way, the application gets new virus database.
5. Schedule antivirus scanning.
6. If your antivirus application do not have scheduled scanning, plan it.
7. Install antivirus widgets or extension in your web browser.
8. For maximum protection, you can install another antivirus application.
9. Uninstall risky applications.
10. Scan flashdrives before opening or exploing those. Avoid borrowing flashdrives.
11. Avoid inserting your flashdrives to other devices.
12. Defrag your system. Some virus can't be detected because your system's drive may be badly fragmented.

3 0
3 years ago
which of the following is acomputer program that detects, prevents. and takes action sto deactivate or remove malicious programm
Len [333]

Answer:

antivirus software is the answer to prevent computer from malicious program

8 0
2 years ago
Which part of the Word screen matches label B?
Flura [38]

The part on the Word screen that matches label B is number b because it says what part of the word matches label B. So it would obviously be label B Ribbon.



Hope this helped.


3 0
3 years ago
Other questions:
  • How to do pseudocode and flowchart in BMI ( computer programming ​
    11·1 answer
  • 11. Print Layout, Full Screen Reading, Web Layout, Outline and Draft are examples of _______. 12. What do you do if the spelling
    5·1 answer
  • Font size, font style, and _______ are all aspects of character formatting.
    14·2 answers
  • Who is gossip girl.....
    8·2 answers
  • Recall that in C++ there is no check on an array index out of bounds. However, during program execution, an array index out of b
    9·1 answer
  • White lines
    7·2 answers
  • Why is it important to install updates? Why should you use the Power button on the Start menu instead of the Power button on you
    7·1 answer
  • Enumerate the the risk in the preparation and cooking in starch and cereal dishes and other food​
    11·1 answer
  • Which of the following is a quality of a mixed economy?
    5·1 answer
  • Does anyone know how to write this right? This is for a coding class and I’m super confused on it.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!