Question

In: Computer Science

write a function that return a list of row numbers in matrix with removing the wrong...

write a function that return a list of row numbers in matrix with removing the wrong value.
Ex: remove_row( matrix, wro)
if matrix = [[5,2,8],[6,7,20],[10,25,9]] wro= 20 then output will be [1,2]
Do not use any built in functions.

Solutions

Expert Solution

matrix = [5,2,8;6,7,20;10,25,9]
wro = 20
function output = remove_row(matrix, wro)
    n_rows = size(matrix, 1)
    n_cols = size(matrix, 2)
    output = []
    count = 0
    for r = 1:n_rows
        flag = 0
        for c = 1:n_cols
            if(matrix(r,c) == wro)
                flag = 1
            end
        end
        if(flag == 0)
            count = count + 1
            output = [output count]
        end
    end
end
remove_row(matrix, wro)


If you have any doubts please comment and please don't dislike.


Related Solutions

Write a Racket function that will take a list of numbers as a parameter and return...
Write a Racket function that will take a list of numbers as a parameter and return true if they all are positive, and false otherwise. You are NOT required to check the type of elements in the list. (please do on racket language)
Write a function which receives a list and returns a number. In the list, all numbers...
Write a function which receives a list and returns a number. In the list, all numbers have been repeated twice except one number that is repeated once. The function should return the number that is repeated once and return it.write a python program for this question. use main function.
Write a Python program that calls a function to sum all the numbers in a list...
Write a Python program that calls a function to sum all the numbers in a list and returns the result to the caller. The main program creates a list (with hard-coded or user input) and passes the list as an argument to the function. You may not use the built-in function, sum. The program calls a second function to multiply all the numbers in a list passed to it by main and returns the product back to the caller. List...
1. Write a function named “Number” that reads in a list of numbers until the user...
1. Write a function named “Number” that reads in a list of numbers until the user enters 0. It will return true if the user has entered more even numbers than odd numbers; otherwise it returns false. 2. Write a code segment to sort an array of students in ascending order of their IDs. Assume the array has been filled with names and assume the following declaration: struct Student { string name; int ID; } Student roster[30]; // Code to...
Write a Matlab function for a matrix that takes in a matrix in echelon form and...
Write a Matlab function for a matrix that takes in a matrix in echelon form and will return the row canonical form. The function cannot use rref, or any other matlab built in functions.
In python, write a function, called ThreeSum, that accepts a list of non-negative numbers as input,...
In python, write a function, called ThreeSum, that accepts a list of non-negative numbers as input, and returns the highest sum of three neighboring elements in it. Write a main method that initializes the following five lists, gets the ThreeSum result for all of them using the above function, and prints the result to the screen. Example of the output: List 1: [4,5,4,5] , Three sum = 14 List 2: [7] , Three sum = 7 List 3: [ ]...
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. IN C Program.
Find the basis for the row space, columnspace, and nullspace for the following matrix. Row 1...
Find the basis for the row space, columnspace, and nullspace for the following matrix. Row 1 {3,4,0,7} Row 2 {1,-5,2,-2} Row 3 {-1,4,0,3} Row 4 {1,-1,2,2}
The following matrix is in reduced row echelon form. Decode from the matrix the solution of...
The following matrix is in reduced row echelon form. Decode from the matrix the solution of the corresponding system of linear equations or state that the system is inconsistent. (If the system is dependent assign the free variable the parameter t. If the system is inconsistent, enter INCONSISTENT.) 1 0 5 −4 0 1 −8 10 0 0 0 0 (x1, x2, x3) =
11. Given a row echelon form or the reduced row echelon form of an augmented matrix...
11. Given a row echelon form or the reduced row echelon form of an augmented matrix of a system of equations, determine the number of solutions the system has.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT