I need some non-repeated random values of variable A
For example:
Variable A=[1 2 3 4 5]
Answer should be any three random values of A.
Answer =[1 5 2] or [1 3 4] or [3 2 4] etc. but not [1 1 5] or [5 3 5] [1 1 1]etc.
You can do this using the datasample function:
http://www.mathworks.it/it/help/stats/datasample.html
For example, to extract three values from the vector A:
y = datasample(A, 3, 'Replace', false)
This works also if A is a matrix, an N-dimensional array or a dataset array.
If for any reason you have not access to this function, you can use randperm:
y = A(randperm(length(A), 3))
In this case, if A is a matrix and not a vector, you have to work on a vectorized version of it: A = A(:).
Hope this helps.
Another possibility:
y = A(randi(numel(A),3,1))
Datasample and randsample can be used.
Dear Simone Scardapane, Mattia Saccoccio & Deepak Bharti
Yes this is a perfect solution.
I have solved by using this
n2=[4 6 9];
f2=[0 1 1 0 1]
n11=([n2(find(f2==0))]);
Thank You very much
Best answer is
>> n = 3;
>> A = [1 2 3 4 5];
>> randsample(A, n)
Does anyone know if randsample can be nested safely with parfor? I seem to recal a problem with random number generation between parfor processes.
Almost all the optimization algorithms considers Function Evaluations to compare performance among various algorithms. Do Function Evaluations number is the most important criteria? If yes/no why?
10 November 2017 1,516 18 View
Recently, University Grants Commission (UGC), Government of India approved more than 44000 journals (http://www.ugc.ac.in/journallist/). This list has the inclusion of a large number of predatory,...
07 August 2017 7,287 33 View
Dear all, A smart war against corruption and terror, put up by Government of India. Will it strike on Black money makers? Can we stop corruption? Does it resist terror? What...
10 November 2016 4,606 36 View
Dear all, Most of the research papers are showing academic applications of the various truss structure. I would be glad if you please share some real world examples of various truss structures (as...
06 July 2016 4,536 26 View
In our society one day publication (submission and publication can be done in a day) and publication with reputed journals (Thomson Reuters, which takes months (or years)) have no big difference...
02 March 2016 7,960 67 View
Dear all, Please share your view and relevant materials for symbolic regression in optimization methods. Thanks
02 March 2016 1,747 5 View
Now a day large number of international journals offer speedy publication (by next day/week) with various types of impact factor / indexing. Such, journals are not checking plagiarism, originality...
06 July 2015 8,483 33 View
Dear Friends, How to check grammar and language of the research paper writer by non native English speakers.
05 June 2015 9,005 5 View
Dear all, I am looking for study material and basics of composite unconstrained benchmark functions. I have gone through many research papers. Composite functions are stated in various research...
03 April 2015 5,746 4 View
Dear all, I am new to Latex hence seeking for your valuable. I have three equations that need to convert in LaTex to submit my research paper. This equations are converted in LaTex (double column...
03 April 2015 8,075 1 View
I would like to understand potential safety concerns while handling SEB in the lab. Especially while working in animal house facility. Would like to know precautions for handling. Sigma MSDS...
07 August 2024 6,034 3 View
During low-temperature testing, new diffraction peaks that appear could be indicative of several phenomena. In one of our tests, we observed notable new peaks around 40° and 45° in a specific...
06 August 2024 726 3 View
Is it possible to conduct a molecular dynamics simulation to see the effects of a specific carbohydrate on the structure of lipids (e.g., micelle structure)? I am a beginner in this field and plan...
03 August 2024 3,371 3 View
I am using a windows system, what software I should use for hydration shell analysis with molecular dynamics?
02 August 2024 3,143 4 View
Can we patent a process flow diagram developed using a process simulator but no actual cases is carried out? For example consider a process for certain product manufacture where a new process flow...
31 July 2024 781 1 View
I am new to Micromechanics and having similar problem with understanding the implementation of the formula's. I would appreciate if anyone can guide me on how to go about getting a scalar value...
30 July 2024 969 0 View
Some Staphylococcus aureus strains Inhibit the growth of Mycobacteria in Mueller Hinton Agar medium containing 10% OADC. Do some Staphylococcus aureus strains have in vitro antimycobacterial activity?
29 July 2024 10,023 2 View
Dear All Gromacs User I would like to restart MD without using checkpint .cpt files? I heard there is a way for acheiveing this. Any input and sugegstions are most welcome. Thanking You Budheswar
29 July 2024 3,084 8 View
If I want to calculate molecular dynamics (Gromacs), do I first need to optimize the geometry of the molecule? For example, I first draw the molecule in Avogadro, and then what? I guess I can't...
28 July 2024 673 3 View
Please, what is the memory consumption of the Matlab function quad tree decomposition procedure [S = qtdecomp(I)] with respect to the input set I?
27 July 2024 5,455 2 View