I have met a question that "If babble1 is 1 then thebabbled frame is generated randomly with a sequence number between 0 to 255."So i need to define a inline functino to get a random data.Should I include a rand.h in C to Spin?Or there is another solution?
Related
I would like to ask about the creation of the Sobol sequence.
I want to sample quasi-random number generation, but I know that I can use the sobolset in the matlab.
However, when you use it, you sample a number from 0 to 1.
I want to freely designate the range.
For example, I want to range from 2 to 100, or from 10^-7 to 10^-3.
I ask for your help
I need some help of solving that issue: I have 5 different voltage values that change every single tick time - that mean every single moment. I need to sort them and after they been sorted I want to go to another matrix(like this one at the bottom) and to pull out(read) specific column from it, for every state pre define(timing that I am designing..) That mechanism change every single states/moment. How can I do this ?
The Matrix look like(and could be greater...):
0 0 0 1 1 1...
0 1 1 0 0 1...
1 0 1 0 1 0...
1 1 0 1 0 0...
.. .. .. .. .. ..
Thanks, Henry
I am not sure I understood it correctly. So I will edit my answer after you make your question a bit more clear.
I see two separate things:
Reading 5 voltage values which change at each step. You want to sort these values. To do this you can use the sort function of matlab. It is really easy to use and you can look at it here.
This is the part I didn't understand well. After sorting the voltage readings what do you want to do with the matrix ? If you want to access just a specific column of the matrix and save it in a variable you can do it in this way. Let's assume you have a matrix A which is N x N, if you want to access the 10th column of the matrix and store it in a variable called column10 you will do something like: column10 = A(:,10)
I hope this will help you but let me know if this is what you wanted and I will edit my answer according to it.
Fab.
I have a set of numbers and I want to use predictive coding to get smaller values for this set of data as each value should not differ to much from the last. I was just starting very simply with a expected value that each value would be the same as the last, and then just store the error.
For some simple data:
1 2 -3 1
The values I should get are
1 1 -5 4
The way I was doing this compression was one line, but to decompress I need the last value, so I put this in a loop. Is there a way to do this, and possibly more complex(looking at more the just the last value) predictive coding without needing to use Matlab loops.
As suggested by #Divakar, constructing the new values can be done by
B = [A(1) diff(A)];
Obtaining the original from this result, the inverse of the above procedure, is done through
A = cumsum(B);
I want to generate a matrix of random numbers (normrnd with mean == 0) that satisfy the following constraints using MATLAB (or any other language)
The sum of the absolute values in the matrix must equal X
The largest abs(single number) must equal Y
The difference between the number and its 8 neighbors (3 if in corner, 5 if on edge) must be less than Z
It would be relatively easy to satisfy one of the constraints, but I can't think of an algorithm that satisfies all of them...
Any ideas?
I am not sure whether to edit my post or to reply here, so I am editing... #MZimmerman6, you have a point. Though these constraints won't produce a unique solution, how would I obtain multiple solutions without using rand?
A very simply 3 x 3 where 5 is the max element value, 30 is the sum, and 2 is the difference
5 4 3
4 4 2
3 2 3
Rody, that actually may help...I need to think more :)
Luis ...Hmmm...why not? I can add up the absolute value of a normally distributed sample...right?
Here is an algorithm to get the 'random' numbers that you need.
Generate a valid number (for example in the middle)
Determine the feasible range for one of the numbers next to it
If there is no range, you go to step 1, otherwise generate a number and continue
Depending on your constraints it may take a while of course. You could add an other step to see if changing the existing numbers would help before going back to step 1.
Is it possible to generate a random integer from a list of numbers or predefined set - that may not be in order.
For example - generate a random number from 1,2,4,5 (no 3 allowed).
You can create an array with all your predefined set into it, then you fill an integer index with a random number from 0 to the array's length. That should do the trick :)