Stepping over / removing duplicate points

1 次查看(过去 30 天)
If I want to populate B with derived values from Matrix A using the following specifiers how could I do this?
Point 1 = 800 (A(1,1))
I then want to populate the B matrix (1,1) with the first point 2 value.
The observation equation would be B(1,1) = A(1,1) + A(1,3)
I then want to run through the B matrix using that elements value + the corresponding element in A(:,3), ie the B matrix element position to look for the same value throughout A. See further down for further explanation.
Counter_1 = 1
Counter_2=1
Row_count = 1
m = 1
To_specifier = 1
Delete_count =1
Del_from_B =1
Val = 1
for Counter_1 = 1:7
for Counter_2 = 1:10
if A(Row_count,2) == Val
B(To_specifier ,1) = A(1,1) + A(Row_count,4)
s=s+1
A(Row_count,2) = 0 % used to show what code is doing throughout breakpoints.
else if A(Row_count,2) == Val +1 % point #2
B(A(Row_count,3) = B(s-1,1) + A(Row_count,4)
A(Row_count,2) = 0
end
val = val+1 % want to then peruse the next point value in increasing sequence.
I want to also put a subroutine in the code so that if there is a value in element B that element number (position of element and not value inside it), will be removed from all of the A(:,3) thus removing any duplicate calculations for that point.
A=
800 1 2 4.3
NaN 2 4 3.6
NaN 3 6 2.1
NaN 4 3 4.8
NaN 5 7 11.1
NaN 6 3 -12
NaN 6 5 -4
NaN 1 4 -17
NaN 2 5 -15
NaN 3 6 -7
B = zeros (1:6)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by