MATLAB Answers

Filtering specific variable in 20*380 imported table, like we do in excel.

27 views (last 30 days)
chirag desai
chirag desai on 30 Jun 2020
Commented: Rik on 22 Jul 2020 at 19:50
I would like to apply filter to the imported 20*380 line table format excel sheet.
Lets say I have improted excel sheet named 'D" and from this excel sheet I would like to filter 'speed' column like speed ranging from > 2600 and < 2000. and apply this filter to entire excel sheet
now post applying htis filter need to save this excel in matlab with different name and would like to use it further for plotting.
Please suggest the way forward for this operations.

  7 Comments

Show 4 older comments
Rik
Rik on 21 Jul 2020 at 12:27
How did you load the data in Matlab? As an array or a table? If you loaded it as an array, you only need to modify which column is used to create L. If you loaded as a table you can use the column name directly.
chirag desai
chirag desai on 22 Jul 2020 at 10:12
model = questdlg (' Select Data file' , 'select',...
'Data','Cancel','c')
switch model
case 'Data'
disp('select Data file')
per=1;
case 'Cancel'
per=2;
end
for R=1:2
if per ==1
[file,path] = uigetfile('*.*',...
'Select One or More Files', ...
'MultiSelect', 'off');
if isequal(file,0)
disp ('User selected cancel');
else
disp(['User selected ', fullfile(file,path)]);
S=readtable([path '\' file]);
break
end
end
if per ==2
Button = buttondlg('Error!','Error','You must select Data file first', ...
struct('Default','Continue','IconString','error'));
switch Button
case 'You must select Data file first'
disp('select Data file')
per=1;
R=R+1;
end
end
end
%% Filtering
S=1800+1000*rand(385,294);
D= S (:,ENG_SPD)<2400 & S(:,ENG_SPD)>2200;
With this line I am facing following Error!!
Error in Data_Trends_Master_Scripts_Rev01 (line 50)
D= S(:,ENG_SPD)<2400 & S(:,ENG_SPD)>2200;
Rik
Rik on 22 Jul 2020 at 19:50
Why are you overwriting S? I created it to have an array to show how you can modify it.
Also, please use the edit tools to format your code properly. I'm on mobile, so I can't easily edit it for you.
For future reference: the only relevant line is the line where you actually load the data: the line with readable. We only need to know you're using that, and to have your file to completely reproduce your problem.

Sign in to comment.

Answers (0)


Translated by