フィルターのクリア

How to save mat file in Matlab

5 ビュー (過去 30 日間)
Med Future
Med Future 2022 年 2 月 2 日
コメント済み: Voss 2022 年 2 月 7 日
Hi all, i hope you are doing well, i have the dataset file of shape 9920x1
i modify the mat file and want to save each mat files with shape of 1024x1 in folder How can i do that?
and generate 100 mat file from a single mat file

採用された回答

Voss
Voss 2022 年 2 月 2 日
This will generate 10 mat files, 9 of which contain a 1024x1 variable of contiguous samples from your original mat file and 1 of which contains the remaining 704 samples:
fn = '64qam12';
S = load([fn '.mat']);
block = 1024;
N = ceil(numel(S.var5)/block);
for i = 1:N
var5 = S.var5((i-1)*block+1:min(i*block,end));
save(sprintf('%s_%d.mat',fn,i),'var5');
end
Alternatively, this wil save 10 mat files, each of which contains a 1024x1 matrix, the last of which is padded with NaNs on the end:
fn = '64qam12';
S = load([fn '.mat']);
block = 1024;
N = ceil(numel(S.var5)/block);
S.var5 = [S.var5; NaN(N*block-numel(S.var5),1)];
for i = 1:N
var5 = S.var5((i-1)*block+1:i*block);
save(sprintf('%s_%d.mat',fn,i),'var5');
end
  3 件のコメント
Med Future
Med Future 2022 年 2 月 2 日
@Benjamin and how to generate the 100 file from single file generated by this code
Voss
Voss 2022 年 2 月 7 日
This code generates 10 files. Not clear where 100 files would come from.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeReporting and Database Access についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by