0
我有導入文本文件到MATLAB下面的腳本,其中包括每小時的數據,在這裏我再嘗試將它們轉換成每日平均值:MATLAB平均
clear all
pathName = ...
TopFolder = pathName;
dirListing = dir(fullfile(TopFolder,'*.txt'));%Lists the folders in the directory specified by pathName.
for i = 1:length(dirListing);
SubFolder{i} = dirListing(i,1).name;%obtain the name of each folder in
%the specified path.
end
%import data
for i=1:length(SubFolder);
rawData1{i} = importdata(fullfile(pathName,SubFolder{i}));
end
%convert into daily averages
rawData2=cell2mat(rawData1);
%create one matrix for entire data set
altered=reshape(rawData2,24,(size(rawData2,2)*365));
%convert into daily values
altered=mean(altered)';
%take the average for each day
altered=reshape(altered,365,size(rawData2,2));
%convert back into original format
我的問題就在於試圖轉換數據恢復成與'rawData1'相同的格式,'rawData1'是每個變量的單元格(其中每個變量都用'SubFolder'表示。這樣做的原因是除了其中一個變量外,其餘變量都是矢量一個矩陣(8760 * 11)
所以,一個例子是:
clear all
cell_1 = rand(8760,1);
cell_2 = rand(8760,1);
cell_3 = rand(8760,1);
cell_4 = rand(8760,1);
cell_5 = rand(8760,1);
cell_6 = rand(8760,11);
cell_7 = rand(8760,1);
cell_8 = rand(8760,1);
cell_9 = rand(8760,1);
data = {cell_1,cell_2,cell_3,cell_4,cell_5,cell_6,cell_7,cell_8,cell_9};
,我需要每個單元轉換從小時值到日常平均值「數據」(即365行)。
任何意見將不勝感激。