Azzera filtri
Azzera filtri

How to save mat file in Matlab

5 visualizzazioni (ultimi 30 giorni)
Med Future
Med Future il 2 Feb 2022
Commentato: Voss il 7 Feb 2022
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

Risposta accettata

Voss
Voss il 2 Feb 2022
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 Commenti
Med Future
Med Future il 2 Feb 2022
@Benjamin and how to generate the 100 file from single file generated by this code
Voss
Voss il 7 Feb 2022
This code generates 10 files. Not clear where 100 files would come from.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Reporting and Database Access in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by