List the last three elements of vector H (for example H = 2:5:70) using a Matlab
ID: 3788348 • Letter: L
Question
List the last three elements of vector H (for example H = 2:5:70) using a Matlab command and store them inside H2. H can be any vector. H2 = H(last(3)) >> H2= H(end-3: end) H2= H(end-2: end) H2 = H(1: 3) How to do create a column vector K which is the third column of this matrix M=[l:3; 5:7; 10:12]: >> K = M (:, 3) >> K = M(1:3, 3) >> K = M ([1, 2, 3], 3) The first three answers are all correct. >> K = M (3, :) To display the text "I love Matlab!", one may enter: disp(I love Matlab!) display(I love Matlab!) display(" I love Matlab!") disp("I love Matlab!") To obtain the value of a parameter or a string from the user, what would be the appropriate command to use? fprintf input dips formatExplanation / Answer
Question-9
Correct option : H2=H(end-2:end)
Explanation: H(end-2:end) access the range of elements from the index end-2 to end I,e H(end-2), H(end-1) and H(end).
-----------------------------------------------------------------------------------------------------
Question-10
Correct option: The first three answers are correct
Explanation:
K=M(:,3) : creates a column vector with data in 3 rd column of entire rows of M I,e 3,7,12
K=M(1:3,3) : creates a column vector with data in 3 rd column of 1st row to 3rd row of M I,e 3,7,12
K=M(1:3,3) : creates a column vector with data in 3 rd column of 1st row,2nd row, and 3rd row of M I,e 3,7,12
All above 3 answers is correct
K=M(3,:) : create a row vector with 3rd row of M : not a correct option
--------------------------------------------------------------------------------------------
Question-11
Correct option : disp(‘ I love Matlab!’)
Explanation : disp (‘String expression’) and display(‘string expression’) are the methods to print the string, A string is always enclosed with a pair of single quotes.
----------------------------------------------------------------------------------------------------------------------
Question-12
Correct option : input
Explanation: fprintf is a formatted output function. Disp is the output function. Format changes the input/output format.
Input is the function that accepts input from user
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.