Referencing variables in an array

Very novice MATLAB user. I have a matrix and a function that includes the rows to delete. How do I delete those rows referencing the function?
This is what I have:
x = find(final_allocation~= 0);
rowdrop = preferences(:,1) == [x];
preferences(rowdrop,:) = []
---
x = [1 2 4]
preferences =
2 7 9 6 5 4 1 3 8
4 6 1 9 5 3 2 7 8
4 2 6 7 9 5 3 8 1
1 5 2 3 9 4 7 8 6
3 8 6 9 2 4 1 7 5
7 8 1 2 4 6 3 9 5
2 4 3 1 8 9 7 6 5
5 1 2 9 4 7 8 3 6
6 1 8 5 2 9 4 7 3
I want to delete rows 1, 2, and 4 using variable x.

Answers (1)

If you want to remove the [1 2 4]th row of a matrix
x=[1 2 4];
a=magic(6);
a(x,:)=[];

Categories

Asked:

on 25 Feb 2019

Answered:

on 25 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!