Answered
Conditional statements not catching
Looks like your code is intended to have arrays as inputs. Because of this, *none* of your if-else-etc checking is going to wor...

10 years ago | 0

| accepted

Answered
why zero to the power of zero is not NaN?
Having 0^0 = 1 is a choice MATLAB made and is in agreement with many authors. But this can either be OK or not OK for your appli...

10 years ago | 1

Answered
Multiply slices of a 4D array with vectors without nested loops? Is there a function comparable to pagefun for the CPU?
Some FEX options to consider (some of them involve mex routines): http://www.mathworks.com/matlabcentral/fileexchange/8773-mu...

10 years ago | 0

| accepted

Answered
I want to use a function that is 1 at x=0 and 0 otherwise.I defined a new function impulse ,but it gives an error not enough input arguments.please help me.
Is this code in a file named impulse.m? And are you calling it as follows? result = impulse(some_input);

10 years ago | 0

Answered
Can I have a code that detects # of element transitions and return a matrix that has only rows of minimum element transitions?
Assuming you compare a row to the previous row and allow at most one element to change, you can use the results of diff(A), coun...

10 years ago | 0

Answered
Could someone explain why the below code shows an error like "FUNCTION keyword use is invalid"? I have attached the code below.
My guess is this is all one script file. You cannot define functions like that in a script file. So split this code into two fi...

10 years ago | 0

Answered
Matrix A & B need to be merged, Can I delete a complete raw if one appears in both matrices and same column position?
This was already answered in your other post, but I will repeat it here. k = ~any(bsxfun(@and,A,B),2); % identify rows wher...

10 years ago | 1

| accepted

Answered
how to rotated a cube 30 deg counterclockwise around the axis that passes through v1 and v8
You can do the following steps: 1) Use v1 and v8 to form a unit rotation axis x 2) Use x and your desired rotation angle...

10 years ago | 0

Answered
what does this command: "@(x) Function" means in matlab?
That's a function handle. See this link: http://www.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html?se...

10 years ago | 15

| accepted

Answered
how can I generate a code based on specific value selection in a matrix?
Here is one way as long as x is not too large. This technique will use too much memory if x is too large. b = dec2bin(0:2^n...

10 years ago | 2

| accepted

Answered
Understanding the syntax meaning behind (:,)
The colon : as a subscript simply means "all of the values" for this subscript. So e.g. c(:,j) is all the rows of the j'th colu...

10 years ago | 0

| accepted

Answered
displaying all values from a loop
Is this what you want: con = zeros(size(od)); for n=1:2:11 con(:,n:n+1) = od(:,n:n+1) * E'; end

10 years ago | 0

| accepted

Answered
Help please solve 3nd Order Differential Equation using ODE45
Follow the 2nd Order example given in the doc (the one under "van der Pol equation"): http://www.mathworks.com/help/matlab/re...

10 years ago | 1

| accepted

Answered
Vector search in a loop?
x = find(d==41); d(x) = z(x);

10 years ago | 0

Answered
How would I input the reverse of a natural log code?
result = exp(x) + 5 - exp(1) ./ y; Or maybe you intended something like this: result = exp(x + 5) - exp(1 ./ y);

10 years ago | 0

Answered
Write a function called halfsum that takes as input an at most two-dimensional array A and computes the sum of the elements of A that are in the lower right triangular part of A
Ask yourself, "what does it mean to be in the lower right triangle" in terms of i and j? I.e., what test could you make on i an...

10 years ago | 1

| accepted

Answered
Continious subtraction of a elements in an array
result = diff(A);

10 years ago | 0

Answered
Simple column vector - random number question.
You need to apply the floor() function to rand to get integer results, and your range multiplier isn't quite correct for the ran...

10 years ago | 0

| accepted

Answered
How to efficiently update a matrix in Parallel?
In general, anytime you change elements in a sparse matrix to/from zero to non-zero, the *entire* matrix must be copied in memor...

10 years ago | 0

Answered
Operator ~= matrix dimensions doesn't match
To pick off the cell elements that are not equal to 'False start': pvt(~strcmp(pvt,'False start'))

10 years ago | 0

Answered
how to call fotran code in matlab 7
You can start by reading this documentation and working though the examples: http://www.mathworks.com/help/matlab/programming...

10 years ago | 0

Answered
replacing values in a vector with new value?
v = your vector n = v < 0; % the negative indexes (logical) p = v > 0; % the positive indexes (logical) v(n) = v(n) +...

10 years ago | 0

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

Load more