How to read data from a Excel file and insert data within each sheet in a already created cell array
1 view (last 30 days)
Show older comments
Behrooz Daneshian
on 4 Feb 2023
Commented: Sulaymon Eshkabilov
on 4 Feb 2023
Hi all,
Temperature data for 333 weather stations in Alaska state are stored in an Excel file(each sheet in this file represents data for one weather station). I want to insert data within each sheet of this Excel file in column 8 of an already-created cell array. Please note that I want data within each sheet to be inserted in the cell array as a table. There are already tables in column 8 of the array but these data have missing values, and I want them to be replaced by the data in the Excel file.
It should also be noted that I was not allowed to upload files larger than 5 MB. Hence, I just created representative files( actually, the main Excel file has 333 pages and the main mat file has 333 rows, but here I have just brought 5 stations to show you the concept of my problem).
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 4 Feb 2023
This is how it can be attained:
load('Test.mat') %
FName ='Test.xlsx';
S_names = sheetnames(FName);
for ii=1:numel(S_names)
D{ii}=readtable(FName, 'Sheet', S_names(ii)); % Data read as a table array
stations11{ii,8} = D{ii}; % Inserted in column 8 of the existing variable: stations11
end
2 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!