Answered
If A is a matrix, A(:) produces the columns in a vector. Is there a parallel function for rows?
First, I assume your example result is a typo, since A(:) will return the elements in column order, not row order. E.g., >>...

10 years ago | 4

Answered
Add zero rows to a matrix
Assuming all of the numbers in 1st column of A are increasing positive integers, e.g., result = zeros(max(A(:,1)),size(A,2)...

10 years ago | 0

Answered
Need help determining the order of the eigenvectors output from eig
You might look at this FEX submission by John D'Errico: http://www.mathworks.com/matlabcentral/fileexchange/22885-eigenshuffl...

10 years ago | 0

Answered
An empty do loop giving seg fault with OpenMP while mexing with fortran
Why is adjDist private? This means each thread will work with its own individual copy of adjDist. Is this what you are really ...

10 years ago | 1

Answered
Why is mxGetPi giving an Access Violation?
Some comments on your use of pointers and memory allocation: Mx_in = mxMalloc(sizeof(double) * 100*volume); <-- Delete...

10 years ago | 0

| accepted

Answered
Does the "unique" function work with 64 bit integers?
Maybe use something similar to this as a workaround: y = x(logical([1;diff(sort(x))]));

10 years ago | 0

| accepted

Answered
How to increase speed when taking the max from multidimensional array with -inf?
So, your examples are not the same size for one: N=ones(1,3,2); % <-- Not the same size as your inf example S...

10 years ago | 0

Answered
After using triu, how do I exclude the 0s in the vector?
M = A(triu(true(size(A)),1));

10 years ago | 1

| accepted

Answered
Bug in dcm2quat function
My advice is to put in code to force the continuity that you want. That way you don't have to worry about some edge case that is...

10 years ago | 1

Answered
Generate poisson random number with a mean and standard deviation
See this: https://en.wikipedia.org/wiki/Poisson_distribution And this: http://www.mathworks.com/help/stats/poisson-dist...

10 years ago | 2

| accepted

Answered
How do I shuffle a set of matrix to find the difference with another matrix?
A = whatever B = whatever m = 1000; % Number of trials n = numel(A); C = zeros(1,n); for k=1:m C = C + ...

10 years ago | 0

| accepted

Answered
mex: valid c code crashes Matlab. (integer pointer)
You have a misunderstanding of pointers. This code: int *x = 1; *x = 14; Does the following: The first line declares...

10 years ago | 0

| accepted

Answered
Euler integration for n dimensional system
Looks like you are assigning a vector to a scalar spot with this line: d(fz,1)=y; Try this instead: d(1:fz,1)=y; ...

10 years ago | 0

Answered
if a=[1,2,3,4] how can i get b=[ (1+2),(1+3),(1+4),(2+3),(2+4),(3+4) ] using for loops,Thanks
The limits on your first for-loop are not correct. In particular, length(a-1) is not the same as length(a)-1. And the limits o...

10 years ago | 1

| accepted

Answered
Prime number list checker
Your code for resetting "counter" is inside an if-test. You need to move it so that it always executes. E.g., %#Want to te...

10 years ago | 0

| accepted

Answered
Replace a Fraction of numerical Values with NaN excluding already existing NaN in the Matrix
Does this do what you want? Sets fraction of current non-NaN values to NaN: x = your matrix frac = 0.20; % Fraction of...

10 years ago | 0

| accepted

Answered
Can I Always Change the Order of Operands of Logical Operators?
(Semantics, == and >= and <= are "relational" operators, not "logical" operators. E.g. & and | are "logical" operators.) For ...

10 years ago | 0

Answered
Rewriting a vector addition and multiplication.
D = bsxfun(@plus,sum(A.^2, 2),sum(B.^2, 2)') - 2.*(A*B');

10 years ago | 0

Answered
Assuring mex compatibility on different systems
There is *NO* assured compatibility of compiled mex code across different versions, operating systems, or platforms. The only a...

10 years ago | 0

| accepted

Answered
Can't generate plots of orbit using RK4
Try moving your f code outside of your function code. E.g., : figure() plot(xvar,yvar) end ...

10 years ago | 1

Answered
how to replace char in array with a double
You made a cell array with this line: letters = cellstr(Roman')' That is why you are getting the conversion error. Make ...

10 years ago | 0

| accepted

Answered
Remove cell that contains strings of another cell array
You are changing the size of a in the loop with this line: a(k) = []; So subsequent iteration indexes that depend on ...

10 years ago | 2

| accepted

Answered
How to find mean of a vector including only a specific range of elements
vector = whatever; min_value = whatever; % 15 in your example max_value = whatever; % 25 in your example x = vector >...

10 years ago | 1

| accepted

Answered
How to get a subarray from a matrix
Switch your row and column indexing. E.g. M = N(1:n,end-n+1:end);

10 years ago | 4

Answered
How can I convert the result grid from pol2cart into a uniform Cartesian grid
Does this do what you want: x = [-10:0.1:10]; [X,Y] = meshgrid(x); [PHI,RHO] = cart2pol(X,Y); Z = F(RHO,PHI); N...

10 years ago | 0

Answered
how to convert Decimal degree to degree minutes decimal?
x = your data d = fix(x); f = x - d; result = 100*d + 60*f;

10 years ago | 1

| accepted

Answered
How to fix this error
Use element-wise multiply operator .* instead of * which is matrix multiply: x1= ((.25*pi^2)*(a+b).*((b-a).^2)); % <-- chan...

10 years ago | 2

| accepted

Answered
Quick way to find element by element difference betwen two vectors
mat = abs(bsxfun(@minus,vec2(:).',vec1(:)));

10 years ago | 1

| accepted

Answered
Symbolic 4D array
Not sure why sum(V,4) doesn't work, but reducing it to 2D with some reshapes seems to work: z = size(V); x = reshape(sum...

10 years ago | 0

Answered
Vectorization of a specific matrix product
You could replace the for-loop by this: T = reshape(sum(bsxfun(@times,U,reshape(S,1,k,m)),2),n,m); But, I don't know wha...

10 years ago | 0

Load more