change columns in array to zeros and assign to another vector

hi
I have a (n,3) array, I need to make the first and second coulmns zeros, and assign the resulted array to a new one
g=(a{1}(:,[1 2])==0);
tried this but not work

 Accepted Answer

n = 10 ;
A = rand(n,3) ; % matrix for demo
A(:,1:2) = 0 ; % make first two columns zero
B = A ; % assign tp B

3 Comments

if a is
a =
[21x3 double]
[21x3 double]
[21x3 double]
[21x3 double]
[21x3 double]
how can I do this for all arrays?
v=cell(numel(a),1);
for i = 1:numel(a);
a{i}(:,1:2)=0;
v(i)=a{i};
end
not work
b = a ;
for i = 1:numel(a)
b{i}(:,1:2) = 0 ;
end

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Asked:

on 20 Jun 2020

Commented:

on 20 Jun 2020

Community Treasure Hunt

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

Start Hunting!