How to append cell arrays to from a unique array and then fill one of its column out with data from excel sheets?
Afficher commentaires plus anciens
Hello all,
Using the code below, I am going to load a cell array called "stations_CT" that includes information about all weather stations existing in Connecticut ( ID, start-date and end-date of capturing data, elevation, latitude, and longitude). Then, I am going to fill the 8th column of this cell array using the excel file ("wb_CT.xlsx") including average tempreture data for each weather station( each sheet in "wb_CT.xlsx" corresponds to daily tempreture for each weather station ID existing in the "stations_CT").
I have the same cell arrays like "station_CT"(e.g. "stations_DE", "stations_VT" and...) and the same excel files like "wb_CT.xlsx"(e.g. "wb_DE.xlsx", "wb_VT.xlsx and ...). I need to append all the stations to from a unique cell and then fill out the 8th column of this cell with the corresponding excel files. In other words, I need to create a for loop on my code.
Can anyone help me with this regard?
clear
close all
clc
load("stations_CT.mat")
FName ='wb_CT.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
stations1{ii,8} = D{ii}; % Inserted in column 8 of the existing variable: stations11
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!