How to generate dataset automatically using MATLAB

24 Ansichten (letzte 30 Tage)
Med Future
Med Future am 2 Mär. 2022
Kommentiert: Rik am 3 Mär. 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];
  4 Kommentare
Rik
Rik am 2 Mär. 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
Med Future am 2 Mär. 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 2 Mär. 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
  17 Kommentare
Med Future
Med Future am 3 Mär. 2022
@Rik No the problem is still remaining .
Rik
Rik am 3 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by