# find out negative values and specific values, take it out, record those negative and specific values into a text file

2 Ansichten (letzte 30 Tage)
zhi cheng am 11 Okt. 2022
Kommentiert: Image Analyst am 12 Okt. 2022
given a (52560 x 8 double)
I need to find out the negative values from the last 3 columns, and if the value is 70% more than the sum of last 3 values and next 3 values
then replace the value with the sum of last 3 values and next 3 values divided by 6.
then record those values into a log file(txt file) (X x 3 matrix)
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
zhi cheng am 11 Okt. 2022
I just started doing it, I just done combine data from 3 txt file into 1 matrix, and split the variables.
so far this part, I have no idea how to do it
Image Analyst am 12 Okt. 2022

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Ghazwan am 11 Okt. 2022
The following code should do it. Note that because of the rules you have, you have to skip the first and the last three row.
A=[52560 x 8];
X=zeros(1,3);
for ii=4:length(A(:,1))-3
NValues=zeros(1,3);
for jj=1:3
Sum1=sum(A(ii-3:ii-1,5+jj))+sum(A(ii+1:ii+3,5+jj));
Value= (A(ii, 5+jj)-Sum1)/A(ii, 5+jj);
if A(ii, 5+jj)<0 && Value>0.7
NValues(1,jj)=A(ii,5+jj);
A(ii,5+jj)=Sum1/6;
end
end
if sum(abs(NValues))~=0, X=[X;NValues]; end
end
if length(X(:,1))>1, X=X(2:end,:); end
xlswrite('Values.xlsx',X,1);
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by