フィルターのクリア

Combine mat files into one, then combine all variables into one

4 ビュー (過去 30 日間)
John Madura
John Madura 2022 年 8 月 4 日
回答済み: John Madura 2022 年 8 月 8 日
Hello. I have multiple MAT files all containing the same variables with the same name but different lengths. What I'd like to do is combine all the mat files so that my variables will have the data from all the mat files.
So if I have from mat file one
variable 1=[ 1, 2, 3]
variable 2=[1, 2, 3]
and from mat file 2
variable 1= [4, 5, 6, 7]
variable 2 = [4, 5, 6, 7]
They will combine so that I have mat file 3
variable 1 = [1, 2, 3, 4, 5, 6, 7]
variable 2 = [1, 2, 3, 4, 5, 6, 7]
below is an image showing the mat files and some of the variables.

採用された回答

John Madura
John Madura 2022 年 8 月 8 日
I actually ended up using hte following script which worked for me:
data1 = load("2022_07_28_12_37_19_2022_08_01_17_36_27.mat");
data2 = load("2022_07_28_12_37_19_2022_08_01_17_38_41.mat");
Time = vertcat(data1.variable1, data2.variable1);

その他の回答 (1 件)

Chunru
Chunru 2022 年 8 月 5 日
filename = ["abc001.mat" "def002.mat"]; % list of the files in order
variable1all = [];
variable2all = [];
for i=1:length(filename)
load(filename(i));
variable1all = [variable1all variable1];
variable2all = [variable2all variable2];
end

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by