Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This activity uses a 3rd party app Though your may be recorded aretesh may be re

ID: 3817129 • Letter: T

Question

This activity uses a 3rd party app Though your may be recorded aretesh may be required to update the banner to the left. activity Deleting rows and columns using the colon operator. Assign newMatrixA with origMatri then remove row delRow and column delCol from newMatrixA. Assign deletedElems with the deleted row and column values. Ex lforigMatrixA ist 1. 3, 2:4.9.5:6, 7, 8:1, delRow is 1, and delcolis 2, then newMatrix Ais I4, 5:6, 8:1. and deletedElems is11: 3: 2:9; 7:1. 1 3 2 delRow 4 5 deleted Elems 2 newMatrixA origMatrixA 4 9 5 6 8 6 7 8 Hl save C Reset MATLAB Documentation Your Solution 1 function newMatrixA, deletedElems 1 DeleteRowcolumn origMatrixA, delRow, del col 2 DeleteRowColumn: Delete the row and column specified by delRow 3 and del Col from input matrixA and returns the modified matrix and 4 the deleted elements as a column array. Inputs origMatrixA input matrix deuRow row to delete

Explanation / Answer

function [newMatrixA,deletedElems ] = DeleteRowColumn(origMatrixA, delRow, delCol)
%DeleteRowColumn: Delete the row and column specified by delRow
%and delCol from input matrixA and returns the modified matrix and
% the deleted elements as a column array.
% Inputs: origMatrixA - input matrix
% delRow - row to delete
% delCol - column to delete
%
% Outputs: newMatrixA - input matrix with specified row and column
% deleted
% deletedElems - deleted elements from input matrix returned as
% a column array

%[rows,colms] = size(origMatrixA);

% Assign newMatrix with origMatrix
newMatrixA = origMatrixA;

% Assign deletedElems with row of newMatrixA to be deleted
% (Hint: Use the transpose operator to convert a row to a colmn)
deletedElems = newMatrixA(delRow,:).';

%Remove row delRow from newMatrix
newMatrixA = newMatrixA([1:(delRow-1),(delRow+1):end],:);

%Append deletedElems with the column of newMatrixA to be deleted
deletedElems = [deletedElems; newMatrixA(:,delCol)];

%Remove Column delCol from newMatrixA
newMatrixA = newMatrixA(:,[1:(delCol-1),(delCol+1):end]);

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote