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

Answered
Attempted to access x(5); index out of bounds because numel(x)=4.
The error is caused by ii iterating from 1 to 4, but you use ii+1 (=5 at last iteration) as an index into the x and y vectors wh...

10 years ago | 0

Answered
Fastest way to cycle through a structure for a number
result = find([structure.val]==value); E.g., >> structure(1).val = 50; >> structure(2).val = 47; >> structure(3)...

10 years ago | 0

| accepted

Answered
Parallel Processing An Array/Array Appending
Can you save up all of the arrayToAdd stuff in a cell array and then cat all the results at once at the end to minimize the data...

10 years ago | 0

Answered
how to put output of a function in diagonal of matrix
If y is a vector, then simply y = diag(y); If y is a matrix and you are trying to pick off the diagonal, then e.g., ...

10 years ago | 0

| accepted

Answered
GPS Time conversion from uint8 to decimal
Can you use either of these? >> u = uint8([65 31 163 67 100 90 28 172]) u = 65 31 163 67 100 90 28 172 ...

10 years ago | 0

Answered
\matlab\extern\include\matrix.h(604) : error C2143: syntax error : missing ')' before 'constant',what happen to this ?
Can you compile a bare bones file? E.g., #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, mxArray ...

10 years ago | 0

Answered
table variable name based on array
Do you mean like this: c.(colnames{1}) = a; c.(colnames{2}) = b;

10 years ago | 0

| accepted

Load more