Error in Matlab Data Filtering from an Excel FiIe
I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9);I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9); I have an Excel file that I want Matlab to read, import, then filter (find code below). My problem is, the RowsToKeep variable outputs as an empty array, even though I know there are rows within the data that match the criteria of MLAT between 72 and 82.
Unfortunately, the Excel file I’m using is too large to upload here, even as a zip file. However, I’ve attached a snippet of the file here:
Also, after I run the code below, this is the output from Matlab:
Does anyone know why RowsToKeep gets filtered as an empty array, and how I can fix it? My Matlab code is as follows:
clc;
clear all;
close all;
% Read data from Excel file
data = readtable(‘MLAT_Sat2.xlsx’);
% Convert table to array
data = table2array(data);
% Remove rows with any NaN values
data = data(~any(isnan(data), 2), :);
% Extract columns
%NOTE: column extraction begins at row 2 to ignore the column headings.
time = data(2:end, 1);
angle = data(2:end, 2); % degrees
inclination = data(2:end, 3); % degrees
lat = data(2:end, 4); % degrees
lon = data(2:end, 5); % degrees
alt = data(2:end, 6); % kilometers
MLAT = data(2:end, 7); % degrees
MLON = data(2:end, 8); % degrees
r = data(2:end, 9);
% Find rows to keep with MLAT between 72 and 82
RowsToKeep = find(MLAT >= 72 & MLAT <= 82);
% Filter the data based on RowsToKeep
Filter = data(RowsToKeep +1 , :);
filteredTime = Filter(:, 1);
filteredAngle = Filter(:, 2);
filteredInc = Filter(:, 3);
filteredLat = Filter(:, 4);
filteredLon = Filter(:, 5);
filteredAlt = Filter(:, 6);
filteredMlat = Filter(:, 7);
filteredMlon = Filter(:, 8);
filteredr = Filter(:, 9); data import, data filtering, importing excel data MATLAB Answers — New Questions