Write in MATLAB... 35. Create the following vector C C 1.5 2 2.5 3 3.5 4 4.5 5 9
ID: 3677686 • Letter: W
Question
Write in MATLAB...
35. Create the following vector C C 1.5 2 2.5 3 3.5 4 4.5 5 9.6 9.1 8.6 8.1 7.6 7.1 6.6 6 Then use MATLAB's built-in reshape function and the transpose operation to create the following matrix D from the vector C: 1.5 2 2.5 3 D 3.5 4 4.5 5 9.6 9.1 8.6 8 7.6 7.1 6.6 6.1 By writing one command and using the colon to address a range of elements (do not type individual elements explicitly), use the matrix Dto: (a) Create a eight-element column vector named Da that contains the ele- ments of the first and third rows ofD. (b Create an eight-element raw vector named Db that contains the elements of the second and the fourth columns of D (c) Create a eight-element row vector named DC that contains the first two elements of the first row, the last three elements of the second column, and the first three elements of the fourth row of D.Explanation / Answer
clc;
clear all;
C = [1.5 2 2.5 3 3.5 4 4.5 5 9.6 9.1 8.6 8.1 7.6 7.1 6.6 6.1];
B = reshape(C,4,4);
D = transpose(B);
% 35 (a) generating Da
Da1=D(1,:);
Da3=D(3,:);
Da13=[Da1,Da3];
Da=Da13';
%35 (b) generating Db
Db2=B(2,:);
Db4=B(4,:);
Db=[Db2,Db4];
% 35 (c) generating Dc
x1=D(1,1:2);
x2=B(2,2:4);
x3=D(4,1:3);
Dc=[x1,x2,x3];
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.