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

for input matrix a , write a function to return the element in row 2 column...
for input matrix a , write a function to return the element in row 2 column 3 of that matrix
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 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.
Write a function that will accept a list of numbers and an integer (n). The function...
Write a function that will accept a list of numbers and an integer (n). The function should return a list containing every nth item from the input list, always starting with the first item in the list. The original list should not be modified. For example, if the function is passed the list [8, 3, 19, 26, 32, 12, 3, 7, 21, 16] and the integer 3, it will return the list [8, 26, 3, 16] If the function is...
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.
Assume that the matrix A is row equivalent to B. Without​ calculations, list rank A and...
Assume that the matrix A is row equivalent to B. Without​ calculations, list rank A and dim Nul Upper A. Then find bases for Col​ A, Row​ A, and Nul A. A= [1,1,-2,0,1,-3;1,2,-3,0,0,-6;1,-1,0,0,1,7;1,4,-4,1,13,-11;1,4,-5,0,3,-32] B=[1,1,-2,0,1,-3;0,1,-1,0,-1,-3;0,0,1,1,15,1;0,0,0,0,1,-2;0,0,0,0,0,1]
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...
Write a function that inputs a list of numbers and a percentile value from 0 to...
Write a function that inputs a list of numbers and a percentile value from 0 to 1 and have the function return the element that is at that percentile (or greater than). You can use this website for the steps https://www.indeed.com/career-advice/career-development/how-to-calculate-percentile check out the step for “Follow these steps to calculate the kth percentile” def percentileReturn(list1,percentile):#function which returns the list of elements which are greater than or equal to the percentile list2=[i for i in list1 if i>=percentile] #creating list2...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT