Assume that array array 1 is defined as shown, and determine the contents of the following sub-arrays. $$ \operatorname{array} 1=\left[\begin{array}{rrrrr} 1.1 & 0.0 & 2.1 & -3.5 & 6.0 \\ 0.0 & 1.1 & -6.6 & 2.8 & 3.4 \\ 2.1 & 0.1 & 0.3 & -0.4 & 1.3 \\ -1.4 & 5.1 & 0.0 & 1.1 & 0.0 \end{array}\right] $$ a. array \(1(3,4)\) b. array \(1(:, 3)\) c. arxay \(1\left(1: 2: 3,\left[\begin{array}{lll}3 & 3 & 4\end{array}\right]\right)\) d. array \(1(\\{1 \quad 1], 4)\)

Short Answer

Expert verified
a. \(array1(3, 4) = -0.4\) b. \( array1(:, 3) = \left[\begin{array}{c} 2.1 \\ -6.6 \\ 0.3 \\ 0.0 \end{array}\right] \) c. \( array1(1:2:3, [3, 3, 4]) = \left[\begin{array}{cc} 2.1 & 2.1 \\ 0.3 & -0.4 \end{array}\right] \) d. \(array1(1, 4) = -3.5\)

Step by step solution

01

Understanding the array element reference notation

For understanding how to extract a sub-array, let's understand the array indexing notation: - array(row, column): This notation represents a single element of an array. Here, "row" is the row number and "column" is the column number. - array(:, column): This notation represents an entire column. The colon (:) means "all rows." - array(row:step:row2, column_array): This notation references specific elements with a given step on the rows, and a set of columns represented by the column_array. Now, we can find the requested sub-arrays using this notation.
02

a. array 1(3, 4)

Extract element (3, 4) from the given array, i.e., the element at the third row and the fourth column: \[ array1(3, 4) = -0.4 \]
03

b. array 1(:, 3)

Extract the entire third column from the given array: \[ array1(:, 3) = \left[\begin{array}{c} 2.1 \\ -6.6 \\ 0.3 \\ 0.0 \end{array}\right] \]
04

c. array 1(1:2:3, [3, 3, 4])

Extract elements using the given row and column notation, the rows should start at 1, end at 3, with a step of 2, and the columns should be 3, 3 and, 4: \[ array1(1:2:3, [3, 3, 4]) = \left[\begin{array}{cc} 2.1 & 2.1 \\ 0.3 & -0.4 \end{array}\right] \]
05

d. array 1({1}, 4)

This notation is a bit strange because brackets seems to have missing information. Assuming, it meant '1' for the row, so we need to extract the element from the first row and fourth column: \[ array1(1, 4) = -3.5 \]

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

See all solutions

Recommended explanations on Psychology Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free