Answered
Accelerate Matlab calculation for multi-dimension matrix
As you have written your code, A is a 2D array and yet you have taken four successive sums, which makes no sense. Either you me...

10 years ago | 0

Answered
How to select the particular value and store ias a variable?
r = rand; t1 = (y>=r); t2 = (y<=r); if any(t1) [~,i1] = min(y(t1)); if any(t2) [~,i2] = max(y...

10 years ago | 0

Answered
Can't find the MATLAB error
There should be a comma between \n' and max(waketime(:)).

10 years ago | 0

| accepted

Answered
Image pixels value exceeds 0-255 range, after arithmetic operations on image - How to solve it
I would suggest normalizing the matrix: I = double(I).^3; I = floor(I/max(I(:)));

10 years ago | 0

Answered
decimal to fraction conversion
The 'rat' function returns with an output in the form of continued fractions. To see it as a single fraction, use "format rat"....

10 years ago | 5

Answered
How can I use the multidimensional index returned by max or min?
There is a fairly obvious method using nested for-loops, so I assume you are looking for a vectorized method. I am not at all s...

10 years ago | 0

Answered
How to generate vector of n random numbers between 0 and 1 to x decimal places?
You might be interested in the function I wrote for the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/9...

10 years ago | 0

Answered
Subscript indices error when plotting
This is your problem: X(i,2) = Cv; Y(i,2) = SWR; Matlab is objecting to the fact that 'i' is being used as an index...

10 years ago | 1

| accepted

Answered
Euclidean Distance (Back to the Math...complete with two loops)
Apparently what you want is this: for l = 1:3 for m = 1:3 C(l,m) = sum((A(l,:)-B(m,:)).^2); end end This ...

10 years ago | 2

| accepted

Answered
Inaccuracy in obtaining the Absorption coefficient
In your expression for 'fa' you need to use dots in the division operations on vectors: fa = (((0.11*(xa))./(1+(xa))) + ((4...

10 years ago | 0

| accepted

Answered
Find the best combination of each pair of entries in a matrix
The number of possible bijections for an n-by-n matrix, M, would be n factorial. Use 'perms' to generate all possible permutati...

10 years ago | 0

| accepted

Answered
What is the difference between these two scripts; and which one is more appropriate to use
In "u = squeeze(tdata(1,:,:)./10);" the first level of the first dimension of three-dimensional 'tdata' is divided by 10 and con...

10 years ago | 0

Answered
removing zeros from matrix
A = A.'; A = reshape(A(A~=0),3,4).';

10 years ago | 0

| accepted

Answered
Streamlining Code for Efficiency
TotalNew = bsxfun(@times,(y(:,1)+y(:,2)<=1)&(y(:,2)==y(:,6))&(1-y(:,3)+y(:,1)+y(:,2)>=1),y);

10 years ago | 0

| accepted

Answered
age matching between two groups
There is a very crude brute force method, but it is only practical for a limited range of sizes of the two groups. I suppose fi...

10 years ago | 1

| accepted

Answered
How can I compare two traces in a more efficient way?
See if 'pdist2' would be any faster: A(:,5) = min(pdist2(A(:,1:2),B(:,1:2),'squaredeuclidean'),[],2);

10 years ago | 0

Answered
overlapping area between two circles
Let the distance between the centers of two circles be d and their two radii be r1 and r2. Then the area, A, of the overlap reg...

10 years ago | 1

Answered
How to convert this c code in to matlab.
In the first place, the arrays X13, X14, and X16 will have to be changed to start at index 1, not 0. Matlab does not allow an i...

10 years ago | 1

Answered
Using integral3 to calculate the conditional expectation of an RV
Since you are computing the conditional expected value, you need to divide your integral by the probability of satisfying X>Y & ...

10 years ago | 2

Answered
How to calculate round off error in each step of finite central difference approximation.
The lines e1(i) = f(x-h)-round(f(x-h)); e2(i) = f(x+h)-round(f(x+h)); Roundoff(i) = abs((e2(i)-e1(i))/(2*h)); do ...

10 years ago | 0

Answered
Error using bitxor Matrix dimensions must agree. key1=bitxor(a,b);and key=imresize(key1,[1 256])
As you have written the code, the numbers of elements in 'a' and in 'b' depend on how many bits are required to represent 'sud1'...

10 years ago | 0

| accepted

Answered
how to obtain all combinations of n numbers for following condition
The problem posed in the 'Answer' request below is equivalent to your question with three baskets. The different numbers can be...

10 years ago | 1

Answered
How to integrate x*f(x) in Matlab? f(x) is normal distribution density function.
With f(x) of the form K*exp(-(x-m)^2/(2*s^2)), you can write x*f(x) = m*f(x) + (x-m)*f(x) The integral of the first of th...

10 years ago | 0

Answered
surface area of a 3D surface
If you know the 3D coordinates of each of the three vertices for each triangle in your diagram, then just take the sum of all th...

10 years ago | 3

| accepted

Answered
I'm trying to find what do I need to add to the negative values to get the correct DeltaT? I also need to find where they are negative.
It's as the error message states. You went one too far in 'Min'. Apparently there are 337678 elements in 'Data.min' and in 'Da...

10 years ago | 0

Answered
I have one matrix 5X5 at MatLab, and, for each line, I need to select one random value of one column of that matrix. How can I do that without repeat columns?
I assume by 'line' you mean 'row', and that you want a random column selected in each row without a duplication of columns. Le...

10 years ago | 0

Answered
How to sort vectors so every 1 entry is collected and followed by every 2 entry until the nth entry
s = reshape([a;b;c;...;m],1,[]);

10 years ago | 0

| accepted

Answered
Precision issues when checking for a whole number
Actually x>=0 and either round(x)==x, floor(x)==x, or ceil(x)==x are always valid tests for whether x is a whole number *as stor...

10 years ago | 0

Load more