フィルターのクリア

Filtering a matrix via User Input

1 回表示 (過去 30 日間)
MILLER BIGGELAAR
MILLER BIGGELAAR 2020 年 4 月 1 日
コメント済み: MILLER BIGGELAAR 2020 年 4 月 1 日
Hi guys,
I am trying to create a program that will get the user to select a file and then using the inputdlg command, select a specific set of a filters, then the program will plot the file (in this case 3 columns each with x amount of rows) but filter out the data the user has specified (eg. filtering the min and max limit of column 1 will delete the row corresponding and so on for each column).
[file,path] = uigetfile('*.txt');
if isequal(file,0)
disp('User has selected Cancel.');
else
disp(['User has selected ', fullfile(file)]);
end
Data = readmatrix(file);
Filtering_q = {'Enter Easting Filtering Minimum (m)',...
'Enter Easting Filtering Maximum (m)',...
'Enter Northing Filtering Minimum (m)',...
'Enter Northing Filtering Maximum (m)'};
Filterlims = inputdlg(Filtering_q);
Eastingmin = str2num(Filterlims{1});
Eastingmax = str2num(Filterlims{2});
Northingmin = str2num(Filterlims{3});
Northingmax = str2num(Filterlims{4});
rows_to_delete_Eastingmin = find(Data(:,1)<Eastingmin);
rows_to_delete_Eastingmax = find(Data(:,1)>Eastingmax);
rows_to_delete_Northingmin = find(Data(:,2)<Northingmin);
rows_to_delete_Northingmax = find(Data(:,2)>Northingmax);
Data((rows_to_delete_Eastingmin):(rows_to_delete_Eastingmax):(rows_to_delete_Northingmin):(rows_to_delete_Northingmax),:) = [];
E = Data(:,1);
N = Data(:,2);
D = Data(:,3);
plot3(E, N, D, '.')
This is what I have so far and everything besides the filtering works.
I am using MATLAB 2019a.
  2 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 4 月 1 日
編集済み: Mohammad Sami 2020 年 4 月 1 日
You can use OR '|' or AND '&' to combine your logical statements. you don't need to use find as matlab works directly with logical indexes.
rows_to_delete_Eastingmin = Data(:,1)<Eastingmin;
rows_to_delete_Eastingmax = Data(:,1)>Eastingmax;
rows_to_delete_Northingmin = Data(:,2)<Northingmin;
rows_to_delete_Northingmax = Data(:,2)>Northingmax;
r_del = rows_to_delete_Eastingmin | rows_to_delete_Eastingmax | rows_to_delete_Northingmin | rows_to_delete_Northingmax;
Data(r_del,:) = [];
MILLER BIGGELAAR
MILLER BIGGELAAR 2020 年 4 月 1 日
Thank you but after running both OR | and the AND & command it hasn't actually filtered the numbers out of the Data matrix. Any more suggestions?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by