답변 있음
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...

11년 초과 전 | 1

답변 있음
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...

11년 초과 전 | 2

답변 있음
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 ...

11년 초과 전 | 2

| 수락됨

답변 있음
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 ...

11년 초과 전 | 2

| 수락됨

답변 있음
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);

11년 초과 전 | 2

| 수락됨

답변 있음
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).

11년 초과 전 | 1

| 수락됨

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

11년 초과 전 | 0

답변 있음
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...

11년 초과 전 | 2

답변 있음
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...

11년 초과 전 | 2

답변 있음
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...

11년 초과 전 | 2

답변 있음
??? 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...

11년 초과 전 | 2

답변 있음
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...

11년 초과 전 | 2

답변 있음
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 ...

11년 초과 전 | 2

답변 있음
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 ...

11년 초과 전 | 2

답변 있음
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 ...

11년 초과 전 | 1

| 수락됨

답변 있음
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...

11년 초과 전 | 3

| 수락됨

답변 있음
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"* . ...

11년 초과 전 | 1

답변 있음
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...

11년 초과 전 | 2

답변 있음
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.

11년 초과 전 | 0

답변 있음
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...

11년 초과 전 | 1

| 수락됨

답변 있음
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: ...

11년 초과 전 | 0

답변 있음
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/...

11년 초과 전 | 2

| 수락됨

답변 있음
Calculating Euclidean distance of pairs of 3D points.
Use matlab's 'pdist' and 'squareform' functions

11년 초과 전 | 0

답변 있음
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 ...

11년 초과 전 | 2

답변 있음
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...

11년 초과 전 | 1

| 수락됨

답변 있음
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...

11년 초과 전 | 3

답변 있음
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...

11년 초과 전 | 2

답변 있음
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 ...

11년 초과 전 | 3

| 수락됨

답변 있음
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...

11년 초과 전 | 2

답변 있음
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...

11년 초과 전 | 3

더 보기