How to delete certain values below a function/plot?

I'm trying to delete all values out of a table, which are below values of another table. (The files are attached)
The problem is that my comparison data (SN1520) is in 5° increments, but my measurement data (AWL) is unordered (Only the values of the 2nd and 4th column are important for that). Now I want to clean up the measurement data based on my comparison data, i.e. delete the values in the 4th column of AWL if they are too bad for the value in the 2nd column. Too bad means that they are below the values of SN1520.
So I have tried to plot the SN1520 data and create a function from it:
SN = readtable('SN1520.csv')
figure;
x = SN{:,1};
y = SN{:,2};
plot(x,y);
title('Dependency GPS Elevation');
xlabel('Elevation');
ylabel('GPS');
%Function out of Basis Fitting -> Cubic
gps = 2.03990368077056e-05*x.^3-0.00503162317558603*x.^2+0.466151899356234*x+34.8353383458647;
Now I want to clean up the measurement data using this function so that only good data is available, i.e. values that lie above the function.
I know how to delete the values in each line, but I can't find any code that selects all the data under the function/plot.

댓글 수: 1

If A is matrix and you want to remove all the rows given with indices idx;
A(idx,:) = []

댓글을 달려면 로그인하십시오.

 채택된 답변

Jonas
Jonas 2021년 7월 8일
do you mean you want to remove every y hat is smaller than gps?
x(y<=gps)=[];
y(y<=gps)=[];
plot(x,y);

댓글 수: 4

Markus Vietze
Markus Vietze 2021년 7월 9일
편집: Markus Vietze 2021년 7월 9일
The values in the 2nd and 4th column of AWL and all of SN1520 are the same. First column is elevation, second column is signal-to-noice ratio. I want to remove every value of S/N-ratio at a certain elevationangle in AWL, which is smaller than the S/N-ratio at the same angle of elevation given in my SN1520.file . I hope this is all understandable.
Simon Chan
Simon Chan 2021년 7월 9일
편집: Simon Chan 2021년 7월 9일
Sorry to edit so many times because of some typo error....
A=readmatrix('SN1520.xlsx');
B=readmatrix('AWL.xlsx');
Angle=B(:,3);
SNRatio=B(:,5);
gps = 2.03990368077056e-05*Angle.^3-0.00503162317558603*Angle.^2+0.466151899356234*Angle+34.8353383458647;
SNRatio(gps<SNRatio)=NaN;
B(:,5)=SNRatio;
writematrix(B,'AWL_remove.xlsx')
This write to a new file AWL_remove.xlsx.
Note that the first column of the original file becomes empty, not sure it is ok for you or not.
OR the following preserve all headings and first column
B=readtable('AWL.xlsx');
Angle=table2array(B(:,3));
SNRatio=table2array(B(:,5));
gps = 2.03990368077056e-05*Angle.^3-0.00503162317558603*Angle.^2+0.466151899356234*Angle+34.8353383458647;
SNRatio(gps<SNRatio)=NaN;
B(:,5)= table(SNRatio);
writetable(B,'AWL_remove.xlsx');
Hey, thank you for this answer. Its working.
But I got two problems with it:
  1. I dont want to delete my rows filled with 999, because they are used for different function.
  2. I have to delete all rows, which include the deleted cells.
May you have a idea for this as well? Would help me a lot!
Thanks!
Probably not doing yourself a favor by using readmatrix and all those table2array calls. Read the data as tables, when you need to use thing sin them use dot subscripting, like SN1520.Elevation, SN1520.GPS, AWL.Elevation, and AWL.S_dbHz_. Your code will be much more readable.
If you really want to pull things out of your tables,
Angle=table2array(B(:,3));
is not the best way.
Angle = B.Elevation;
is preferred.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2021년 7월 8일

댓글:

2021년 7월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by