Beantwortet
While loops, please help
Here's something to get you started: x = linspace(0,20,500); will create a vector of 500 values of x uniformly spaced b...

mehr als 11 Jahre vor | 1

Beantwortet
Monte Carlo Pi while loop iterations
Roughly speaking, the expected variance from the mean in an independent random series is proportional to the reciprocal of the s...

mehr als 11 Jahre vor | 2

Beantwortet
Most efficient way to do matrix operation v'*M*v
Assuming the values in V are real, val = 1-sum((V/R).*V,2); If V has complex-valued elements, change that to val ...

mehr als 11 Jahre vor | 2

| akzeptiert

Beantwortet
How to generate Zero mean and unit variance
If you want a uniform distribution do this: n = 1024; x = sqrt(3)*(2*rand(n,1)-1); The random variable x will have ...

mehr als 11 Jahre vor | 2

| akzeptiert

Beantwortet
Multiplying rows of matrix without bsxfun or for loops
a = size(A,1); b = size(B,1); C = A(repmat(1:a,b,1),:).*repmat(B,a,1);

mehr als 11 Jahre vor | 2

| akzeptiert

Beantwortet
how to get 3 indices of the min value?
[~,ix] = min(err(:)); [i1,i2,i3] = ind2sub(size(err),ix); The minimum value is err(i1,i2,i3).

mehr als 11 Jahre vor | 1

| akzeptiert

Beantwortet
Splitting up a vector into a matrix
new = reshape(v,sqrt(length(v)),[]).'; % <-- The transpose is needed

mehr als 11 Jahre vor | 0

Beantwortet
Thanks! Determine εmatch by finding smallest ε = 2^(-k)?
Writing code to determine that should be rather easy. Use a while-loop to repeatedly test whether (1+2^(-k))-1 is non-zero as t...

mehr als 11 Jahre vor | 2

Beantwortet
Using for loops with a recurrence relation to find intervals where the plot acts differently.
You have an error in your recurrence formula, the line y(n+1) = y(n)+h(k)*((-y(n))^2+(4.5*y(n))-3.5); should be y...

mehr als 11 Jahre vor | 2

Beantwortet
Random Variable with exponential distribution of Probablity Density Function
If we call the pdf of y, 'pdfy', then pdfy(t) = 1/(2*a*sqrt(t))*exp(-1/a*sqrt(t)) Note the interesting fact that as t a...

mehr als 11 Jahre vor | 2

Beantwortet
??? Index exceeds matrix dimensions.
I suspect the trouble lies with 'data333'. It may not have as many as 12 columns. If not, the lines "c=(1/(d^2))*data333(j,col...

mehr als 11 Jahre vor | 2

Beantwortet
can any one tell me how this code is working??
This does not seem like good code to me. It is likely that what it does is not what its author intended. For example, if one...

mehr als 11 Jahre vor | 2

Beantwortet
Help solve 2 equations with 4 unknowns
I don't think the approach you describe or anything like it would succeed, David. The 'solve' function is not smart enough for ...

mehr als 11 Jahre vor | 2

Beantwortet
How do I compare two large matrices?
Just modify Rick's code a bit: m = 10; [~,p] = sort(abs(bsxfun(@minus,x,y)),2); new = zeros(size(x,1),m); for ...

mehr als 11 Jahre vor | 2

Beantwortet
store values in array in nested for loop
To get the correct minimum values, replace "clearvars RS" with "ss=1;". If you want to retain a record of these two minimums ...

mehr als 11 Jahre vor | 1

| akzeptiert

Beantwortet
How to write code for hankle and toeplitz matrix?
My apologies! I was not thinking clearly when I wrote the nonsensical A.^(0:9). The following should produce the desired two a...

mehr als 11 Jahre vor | 3

| akzeptiert

Beantwortet
Random number generation problem
You say *"the number of users are greater than the number of channels, so there will be a repetition of channel assignment"* . ...

mehr als 11 Jahre vor | 1

Beantwortet
Question about vector angular separation
This sounds like homework, so I will only give hints. The cosine of the angle between two vectors is equal to their dot product...

mehr als 11 Jahre vor | 2

Beantwortet
How to write code for hankle and toeplitz matrix?
phi = toeplitz(C*A.^(0:9)*B,zeros(1,4)); It is assumed that C*A^n*B is a scalar.

mehr als 11 Jahre vor | 0

Beantwortet
help on randfixedsum error?
The arguments you use for 'randfixedsum' are rather strange! It is the columns whose sum must be 5 and your columns have only on...

mehr als 11 Jahre vor | 1

| akzeptiert

Beantwortet
I need to use for loops to find thematrix product P and Q.
What you are computing there is the Kronecker tensor product: M = kron(P,Q); and not "% M(i,j) = P(i,:)*Q(:,j)". See: ...

mehr als 11 Jahre vor | 0

Beantwortet
how to solve the following Probability density function in matlab?
There is an obvious misprint in the stated interval. It should be: 1/4 0<=x<3 f(x) = 5/...

mehr als 11 Jahre vor | 2

| akzeptiert

Beantwortet
Calculating Euclidean distance of pairs of 3D points.
Use matlab's 'pdist' and 'squareform' functions

mehr als 11 Jahre vor | 0

Beantwortet
solving a non-linear problem
I was overly pessimistic about finding solutions to your most recent set of equations. I had been testing the wrong collection ...

mehr als 11 Jahre vor | 2

Beantwortet
How to plot a function is equal to a constant?
The range for x = -5:5 includes the value x = 0 for which log(0) is minus infinity. I would suggest x = linspace(1,2,1000...

mehr als 11 Jahre vor | 1

| akzeptiert

Beantwortet
why does this trig iteration generates complex numbers?
You are apparently trying to solve the trigonometric equation sin(theta) = (sqrt(d3*d3 - ((h-Ah)-d4*cos(theta))^2) + v + A...

mehr als 11 Jahre vor | 3

Beantwortet
optimal solution of a matrix
It isn't entirely clear what you are asking. If it is allowed to select only a portion of the non-zero values in a column, then...

mehr als 11 Jahre vor | 2

Beantwortet
Most populated range of floating point numbers in array
Perhaps you won't consider this for-loop solution elegant, but it should be computationally efficient. I will assume that your ...

mehr als 11 Jahre vor | 3

| akzeptiert

Beantwortet
Implementing a numerical integration expression
Use matlab's 'integral2' function. It provides for inner integration limits to be functions of the outer variable of integratio...

mehr als 11 Jahre vor | 2

Beantwortet
Associated Legendre polynomials are not orthogonal
As cyclist has noted, the factor 1/(1-x^2) is essential in performing an orthogonality test. The Associated Legendre "polynomia...

mehr als 11 Jahre vor | 3

Mehr laden