number of data = 1000; dimension=20; and save in mat format.

5 Kommentare

jgg
jgg am 7 Jan. 2016
What kind of randomness do you want? There are many ways to generate a random variable. For instance, rand(1000,20) will give you a matrix of the desired size that is uniformly distributed on 0 to 1.
What do you mean by dimension=20? Do you mean it's a 1-D vector with a length of 20 elements or 1000 elements, or do you mean a 20-D array with 1000 length of each dimension (in which case you won't have enough memory)?
If you want this:
data = rand(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000);
then you can't have that and you most likely don't need that.
fred bnm
fred bnm am 7 Jan. 2016
Bearbeitet: fred bnm am 7 Jan. 2016
thanks. rand(1000,20) is ok. but how to assign 4 label classes on this.and please say how to plot that data with labels.
jgg
jgg am 7 Jan. 2016
I'm not sure what you mean? What kind of labels do you want assigned?
the cyclist
the cyclist am 7 Jan. 2016
How about this, fred? Spend the time to compose a complete, coherent description of what it is that you want as input and output from your program. This isn't twitter; feel free to use more than 140 characters.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Jan. 2016

0 Stimmen

data = rand(1000,4);
If the 4 class labels are to be random and equal probability but not necessarily exactly equal number, then
label = randi(4, 1000, 1);
If the 4 class labels must be equal occurrence then
population = [1 * ones(250,1); 2 * ones(250,1); 3 * ones(250,1); 4 * ones(250,1)];
label = population(randperm(1000));
If you wanted a precise distribution that was not equal numbers, then you could adjust the counts in the population matrix.
Your data is 4 dimensional. You cannot plot 4 spatial dimensions. You can encode the 4th dimension as color, but you need to be careful; see http://blogs.mathworks.com/steve/2014/10/20/a-new-colormap-for-matlab-part-2-troubles-with-rainbows/
pointsize = 20;
scatter3(data(:,1), data(:,2), data(:,3), pointsize, data(:,4)); %4th dimension used as color
colormap(parula); %needs R2014b or later
And to add the labels:
labstr = cellstr( num2str(label(:)) );
text( data(:,1), data(:,2), data(:,3), labstr );
this is going to be rather crowded...

Weitere Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by