Create the following problems In MATLAB editor, each problem in a separate m fil
ID: 3887744 • Letter: C
Question
Create the following problems In MATLAB editor, each problem in a separate m file Make sure to have the proper comands for clearing the Comand Window as well as the variables memory in the beginning of your codes Also, write the proper display header for each part Give a short comment in front of each line as needed Proble (1a) -Create a variable calls final_value which is holding a value of 30. (1b)-Create a rou vector from 20 to the final value with an increment of 8. (Do not use the value of final value). Next, assign this vector to a variable calls row vecl. (1c)-Use the lengtho function to create another row vector using linspace ) from 2 to 56 and assign it to another variable calls row vec2 in a way that rowvec2 can be appended to the top of row vecl (1d)-Append row vec2 to the top of row vecl vector and assign it to a variable calls matrixl (Ie)-Append matrixl to the bottom of zow vecl vector and call it matrix2 Change the value of the finalvalue to a new value to the smallest number possible) that your utput becomes 3x4 atrix and assign this matrix to a variable calls matrix3 - (1f)-swap column 4 of matrix2 with column 1. This is your final output. (1g)-Compare matrix2 and matrix3 by generating a Boolean matrix to see which elements are equal (1 if equal and 0 if they are not) Proble 2: (2a)-Using a single built-in function to create a matrix of 4x5 which all the elements are integer numbers between 10 and 20. As ign this matrix to a variable cal1s mat1 (2b)-Using a single built-in function to create a row vector of size 7 which all the elements are integer and randonly picked. The range of numbers must be from 1 to the max value. Assign this row vect to vecl (2c) -Sort vecl ascending and assign it to vecl_sora (2d)-Sort vecl descending and assign it to vecl sor d Problem 3 (3a)-solve for x, y, and z in the following equations, (AX-B: -By left division and assign the results to xleftd -By inverse and assign the results to x inv 3x-2z 6 5x+10y-42-4 3x+2y- 3 (3b)-compare the results in two methodsExplanation / Answer
clc;
clear all;
disp('Problem 1:');
%#################### (1a) ##########################
% defining final_value variable with value 30
final_value = 30;
%#################### (1b) ##########################
% defining row_vec1 row vector with values from 20 to final_value with an increment of 8
row_vec1 = 20:8:final_value;
%#################### (1c) ##########################
% defining row_vec2 row vector with values from 20 to 56 with length equal to length of row_vec1(length of this vector is same as that of row_vec1 so it can be appended to top of row_vec1 vector)
row_vec2 = linspace(20,56,length(row_vec1));
%#################### (1d) ##########################
% append row_vec2 to the top of row_vec1 vector
matrix1 = [row_vec2; row_vec1];
%#################### (1e) ##########################
% append matrix1 to the bottom of row_vec1 vector
matrix2 = [row_vec1; matrix1];
% now changing final_value such that the matrix1 size becomes 3*4 for this row_vec1 should of length 4, and then row_vec2 should be of length 4, then matrix 1 size will be 2*4, after appending this at the bottom of row_vec2, we get matrix3 of size 3*4
% assigning final_value to 44 to make length=4
final_value = 44;
% new row_vec1 of size 4
row_vec1_new = 20:8:final_value;
% new row_vec2 of size 4
row_vec2_new = linspace(20,56,length(row_vec1_new));
% new matrix1 of size 2*4
matrix1_new = [row_vec2_new; row_vec1_new];
% matrix3 of size 3*4
matrix3 = [row_vec1_new; matrix1_new]
%#################### (1f) ##########################
% extract column 1 of matrix2 into variable col1
col1 = matrix2(:,1);
% extract column 4 of matrix2 into variable col4
col4 = matrix2(:,4);
% swap col1 with col4
matrix2(:,1) = col4;
% swap col4 with col1
matrix2(:,4) = col1;
matrix2
matrix3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.