Question

2. Vector variables. Make the following variables a. aVec 3.14 15 9 26) 2.71 28 182 c. cVec [S 4.8 d. dVec-[10° 10 -48 -5] (all the numbers from 5 to-5 in increments of-0.2) (logarithmically spaced numbers between 1 1 l010 and 10, use logspace, make sure you get the length right!) epec = Hello (ere is a string, which is a vector of characters) e. 3. Matrix variables. Make the following variables a. aMat-.. a 9x9 matrix full of 2s (use ones or zeros) b. bMat0 5 0 a 9x9 matrix of all zeros, but with the values ..01 1 2 3 4 5 4 3 2 1on the main diagonal (use zeros, diag) 1 . 91 2 12 .. 92 a 10x10 matrix where the vector 1:100 runs down the 10 20 100 columns (use reshape). NaN NaN NaN NaN d. dMat=| NaN NaN NaN NaN! a 3x4 NaN matrix (use nan) NaN NaN NaN NaN 13 -15 22 10-87 e. eMat= f. Make Mat be a 5x3 matrix of random integers with values on the range -3 to 3 (use rand and floor or ceil) Matrik equations. Using the variables created in 2 and 3, solve the equations below. Use matrix operators. 6. a. xMat (aVecbVec)aMat b. vMa! = bVecalec , note that this is not the same as aVec.bVec c. 2Mat=leMarl (aMat-bMat), where lcMat! is the determinant of cMar, and T again indicates the transpose (use det)

copy the text from the script, paste it into a DOC or PDF. if a Q asks to plot or display something to the screan include the plot & screan output the code generates.

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

Note :

All the parts of the questions have been done and are present in the below code. The question parts are denoted in the comments in the code.

Matlab code for the above questions :

aVec = [3.14 15 9 26] % 2. a)
bVec = [2.71; 8; 28; 182] % 2. b)
cVec = 5:-0.2:-5 % 2. c)
dVec = logspace(0,1,101) % 2. d)
eVec = 'Hello' % 2. e)

aMat = 2 * ones(9,9) % 3. a)
bMat = diag([1 2 3 4 5 4 3 2 1]) % 3. b)
cMat = reshape(1:1:100,[10,10]) % 3. c)
dMat = nan(3,4) % 3. d)
eMat = [13 -1 5; -22 10 -87] % 3. e)
fMat = floor (-3 + 6.*rand(5,3)) % 3. f)

xMat = (aVec*bVec)*aMat*aMat % 6. a)
yMat = bVec*aVec % 6. b)
zMat = det(cMat) * (aMat * bMat)' % 6. c)

Output of the code (according to questions parts):

2. a)

aVec =

3.1400 15.0000 9.0000 26.0000

2. b)

bVec =

2.7100
8.0000
28.0000
182.0000

2. c)

cVec =

Columns 1 through 16

5.0000 4.8000 4.6000 4.4000 4.2000 4.0000 3.8000 3.6000 3.4000 3.2000 3.0000 2.8000 2.6000 2.4000 2.2000 2.0000

Columns 17 through 32

1.8000 1.6000 1.4000 1.2000 1.0000 0.8000 0.6000 0.4000 0.2000 0 -0.2000 -0.4000 -0.6000 -0.8000 -1.0000 -1.2000

Columns 33 through 48

-1.4000 -1.6000 -1.8000 -2.0000 -2.2000 -2.4000 -2.6000 -2.8000 -3.0000 -3.2000 -3.4000 -3.6000 -3.8000 -4.0000 -4.2000 -4.4000

Columns 49 through 51

-4.6000 -4.8000 -5.0000

2. d)

dVec =

Columns 1 through 16

1.0000 1.0233 1.0471 1.0715 1.0965 1.1220 1.1482 1.1749 1.2023 1.2303 1.2589 1.2882 1.3183 1.3490 1.3804 1.4125

Columns 17 through 32

1.4454 1.4791 1.5136 1.5488 1.5849 1.6218 1.6596 1.6982 1.7378 1.7783 1.8197 1.8621 1.9055 1.9498 1.9953 2.0417

Columns 33 through 48

2.0893 2.1380 2.1878 2.2387 2.2909 2.3442 2.3988 2.4547 2.5119 2.5704 2.6303 2.6915 2.7542 2.8184 2.8840 2.9512

Columns 49 through 64

3.0200 3.0903 3.1623 3.2359 3.3113 3.3884 3.4674 3.5481 3.6308 3.7154 3.8019 3.8905 3.9811 4.0738 4.1687 4.2658

Columns 65 through 80

4.3652 4.4668 4.5709 4.6774 4.7863 4.8978 5.0119 5.1286 5.2481 5.3703 5.4954 5.6234 5.7544 5.8884 6.0256 6.1660

Columns 81 through 96

6.3096 6.4565 6.6069 6.7608 6.9183 7.0795 7.2444 7.4131 7.5858 7.7625 7.9433 8.1283 8.3176 8.5114 8.7096 8.9125

Columns 97 through 101

9.1201 9.3325 9.5499 9.7724 10.0000

2. e)

eVec =

Hello

3. a)

aMat =

2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2

3. b)

bMat =

1 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0
0 0 0 4 0 0 0 0 0
0 0 0 0 5 0 0 0 0
0 0 0 0 0 4 0 0 0
0 0 0 0 0 0 3 0 0
0 0 0 0 0 0 0 2 0
0 0 0 0 0 0 0 0 1

3. c)

cMat =

1 11 21 31 41 51 61 71 81 91
2 12 22 32 42 52 62 72 82 92
3 13 23 33 43 53 63 73 83 93
4 14 24 34 44 54 64 74 84 94
5 15 25 35 45 55 65 75 85 95
6 16 26 36 46 56 66 76 86 96
7 17 27 37 47 57 67 77 87 97
8 18 28 38 48 58 68 78 88 98
9 19 29 39 49 59 69 79 89 99
10 20 30 40 50 60 70 80 90 100

3. d)

dMat =

NaN NaN NaN NaN
NaN NaN NaN NaN
NaN NaN NaN NaN

3. e)

eMat =

13 -1 5
-22 10 -87

3. f)

fMat =

-1 -1 -3
-1 -3 -1
1 -2 0
-2 1 -2
1 -1 1

6. a)

xMat =

1.0e+05 *

1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405
1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405 1.8405

6. b)

yMat =

1.0e+03 *

0.0085 0.0406 0.0244 0.0705
0.0251 0.1200 0.0720 0.2080
0.0879 0.4200 0.2520 0.7280
0.5715 2.7300 1.6380 4.7320

6. c)

zMat =

0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0

Add a comment
Know the answer?
Add Answer to:
copy the text from the script, paste it into a DOC or PDF. if a Q...
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
  • MATLAB This is a copy and paste of what we need to do. Enter this in...

    MATLAB This is a copy and paste of what we need to do. Enter this in MATLAB. Please explain what you are doing and why. I don't just want the answer. I want to study this. This is a 100 class and the teacher teaches it as if we are 300 students.... please help me learn not just get the answer % q11_sol.m % % Quiz #11 solutions % February 11, 2020 % %% Part 1 % For the given...

  • 3. Create a MATLAB script or function that takes converts a 10-element array, B, of zeros...

    3. Create a MATLAB script or function that takes converts a 10-element array, B, of zeros and ones and converts it into a floating point number, F, using the following rules: 1. The leading bit indicates a positive (0) or negative (1) number ii. Bits 2 through 4 are the binary representation of e, the exponent Ill Bits 5 through 10 represent the number precision as: (sign).(1 + bit5.2-1 + bith. 2-2 + ... + bit10.2-6). 2-3 iv. Finally, if...

  • You should test out your script using the following matrices. 2 3 1 2 3 1 C D- 3 2 B- A- -3 8 4 8 2 4 4 1 You may n...

    You should test out your script using the following matrices. 2 3 1 2 3 1 C D- 3 2 B- A- -3 8 4 8 2 4 4 1 You may not use any special MATLAB tools. Instead, work symbolically and derive general expressions for the eigenvalues and the eigenvectors. For instance, you may not use the SOLVE function. If you are not sure whether or not a particular function is available to you, just ask Include your hand...

  • For this project, each part will be in its oun matlab script. You will be uploading a total 3 m f...

    For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...

  • answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for...

    answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...

  • 1. For each of the following regression models, write down the X matrix and 3 vector....

    1. For each of the following regression models, write down the X matrix and 3 vector. Assume in both cases that there are four observations (a) Y BoB1X1 + B2X1X2 (b) log Y Bo B1XiB2X2+ 2. For each of the following regression models, write down the X matrix and vector. Assume in both cases that there are five observations. (a) YB1XB2X2+BXE (b) VYBoB, X,a +2 log10 X2+E regression model never reduces R2, why 3. If adding predictor variables to a...

  • Problem 1 (Logistic Regression and KNN). In this problem, we predict Direction using the data Weekly.csv....

    Problem 1 (Logistic Regression and KNN). In this problem, we predict Direction using the data Weekly.csv. a. i. Split the data into one training set and one testing set. The training set contains observations from 1990 to 2008 (Hint: we can use a Boolean vector train=(Year < 2009)). The testing set contains observations in 2009 and 2010 (Hint: since train is a Boolean vector here, should use ! symbol to reverse the elements of a Boolean vector to obtain the...

  • K-means clustering K-means clustering is a very well-known method of clustering unlabeled data. The simplicity of...

    K-means clustering K-means clustering is a very well-known method of clustering unlabeled data. The simplicity of the process made it popular to data analysts. The task is to form clusters of similar data objects (points, properties etc.). When the dataset given is unlabeled, we try to make some conclusion about the data by forming clusters. Now, the number of clusters can be pre-determined and number of points can have any range. The main idea behind the process is finding nearest...

  • can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient...

    can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient MATLAB script to find the eigenvalues and eigenvectors of a 2 x2 matrix input by the user. You should test out your script using the following matrices. 1::)-::) 3 2 3 1 B. 1 2 C 2 3 A- D- 4 1 2 4 4 8 -3 8 You may not use any special MATLAB tools. Instead, work symbolically and derive general expressions for...

  • in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The fu...

    in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The function norm is used for the magnitude of a vector, instead magnitude of a scalar. Function 4.5,1 (netonsys) Newron's method for a system of equations function x=newtonsys (f,x1) 2 % NETONSYS Newton's method for a system of equations 3 % Input : function that...

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