# How to generate dataset automatically using MATLAB

11 views (last 30 days)
Med Future on 2 Mar 2022
Commented: Rik on 3 Mar 2022
Hello everyone, i hope you are doing well
i have the following code, which generate dataset,
out1,out2,out3,out4 has shape of 1x4000.
the dataset has shape of 4x4000.
I want out1,out2,out3,out4 shape to 1x50000 and
each row contain 1000 samples there is 50 rows for each out1,2,3,4,
so row shape is 1x1000
so that the output dataset shape of 200x1000.
Can anybody help me in that;
clc;clear;
prfSTG = [200 400 800 1000 900 ];
n_pulsesSTG = [800 800 800 800 800 800 ];
out1 = repmat(prfSTG,1,(ceil(sum(n_pulsesSTG)/length(n_pulsesSTG))));
prf = [200];
n_pulsesconstant = [4000];
out2 = repmat(prf,1,(ceil(sum(n_pulsesconstant)/length(n_pulsesconstant))));
out3 = (rand(1,4000)*100)+750;
val = [200,500,800,1000,800,900,700,300,600,150];
num = [120,400,830,400,300,450,200,400,500,400];
out4 = repelem(val,num);
%Create a Dataset
dataset = [out1; out2; out3; out4];
Rik on 2 Mar 2022
So you just want to repmat your out variables by a factor 12.5? You will have to choose how to deal with the fact that you don't have an integer multiple you want to end up with.
I also suspect you would be interested in reshape to get your desired shape.
I have no clue what you're attempting to do. Your variable names are mostly meaningless to me and you don't have any comments, so the code is no help to me.
Med Future on 2 Mar 2022
@Rik like out1 is one class out2 is second class, out3 is third class and out4 is fourth class
I want to generate a larger data using the above code.
the above code generate the data of only 4000 samples,
i want to generate 50000 samples for each class

Rik on 2 Mar 2022
Maybe you want this?
total_samples_per_class=5e5;
prfSTG = [200 400 800 1000 900 ];
n_pulsesSTG = [800 800 800 800 800 800 ];
out1 = repmat(prfSTG,1,total_samples_per_class/numel(prfSTG));
prf = [200];
n_pulsesconstant = [4000];
out2 = repmat(prf,1,total_samples_per_class/numel(prf));
out3 = (rand(1,total_samples_per_class)*100)+750;
val = [200,500,800,1000,800,900,700,300,600,150];
num = [120,400,830,400,300,450,200,400,500,400];
out4 = repelem(val,num);
out4 = repmat(out4,1,total_samples_per_class/numel(out4));
%Create a Dataset
dataset = [out1; out2; out3; out4];
size(dataset)
ans = 1×2
4 500000
Med Future on 3 Mar 2022
@Rik No the problem is still remaining .
Rik on 3 Mar 2022
Those two statements are contradictory. Either you needed a vector like the one produced by randi, or you didn't. Which is it?
Please start explaining what you have and what you want. Which vector should be generated, based on what? You really need to answer that properly. If you don't want help, just say so. If you do actually want help, provide the required information.

### Categories

Find more on Matrices and Arrays in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!