필터 지우기
필터 지우기

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 CenterFile Exchange에서 Reporting 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