the matrix a
looks this:
1 1.1 0 2 1.2 0 3 1.3 0 4 1.1 0 5 1.5 0 1 1.0 0 2 0.9 0 3 0.3 0 4 0.1 0 5 0.4 0
the first column represents x
while 2nd represents y
, 3rd z
. see, x
values gets repeated every 5 samples. , z
column zeros, did calculation , want add value @ specific x
, y
value. how can ?
for example if want insert z = 5
value x = 4
, y = 0.1
,
you do
maskrow = a(:,1) == 4 & a(:,2) == 0.1; a(maskrow,3) = 5
explanation:
in first line of code, find rows of matrix satisfies both condition. i.e comparing x
first column , y
second column of matrix a
. maskrow
gives logicals
of true
corresponding row satisfies both above conditions while false
rest of rows.
in second line of code, assign z
values third column of particular row obtained rowmask
Comments
Post a Comment