Transcribed Image Text:### 1.2 Matrix
1. **Create a vector with 100 random numbers.**
2. **Transfer the above vector into a 10 by 10 matrix \( M \).**
3. **Find the transposed matrix \( M^T \).**
- Print the value of the element that is in the second row and the first column of \( M^T \).
4. **Write a nested loop to calculate the inner product between \( M^T \) and \( M \).**
- The result is also a matrix \( N = \langle M^T, M \rangle \).
5. **Calculate the same inner product using operator \(\%\ast\%\).**
- And compare the two results.
Expert Solution
Step 1
Solution -
A) A=rand(200,1) % 200 random numbers use rand or randn
b=randi(200,100,1) % randomly choose 100
A(b)=NaN % replace those 100 chosen above with NaN's
We may use the sample function to generate a random vector for a set of values. The sample function just requires that we pass the range and sample size. For instance, the command sample(1:100,20) can be used to generate a random sample of size 20 for a range of values between 1 and 100. If the sample size is greater than 100, replace=TRUE can be used as seen in the example below.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Example2
x2<-sample(1:100,200,replace=TRUE)
x2
Output-