MATLAB Answers

array and logicals; deleting columns

7 views (last 30 days)
hjo
hjo on 22 Jun 2020
Answered: the cyclist on 22 Jun 2020
Hi I am trying to delete a column of array based on a logical (true, false)
arr = [1 2 3; 4 5 6; 7 8 9];
if the logical is this,
logic = '0 1 0' %this is logical values
I am trying to delete the entire column when its true (logical 1). And the returned value should look like this:
new = [1 3; 4 6; 7 9]
Could you do this by using 'logic'? not arr(:,2)]=[]

  0 Comments

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 22 Jun 2020
Here is one way.
arr = [1 2 3;
4 5 6;
7 8 9];
logic = [false true false];
new = arr(:,not(logic))

  0 Comments

Sign in to comment.

More Answers (0)

Tags


Translated by