Solved


Find all elements less than 0 or greater than 10 and replace them with NaN
Given an input vector x, find all elements of x less than 0 or greater than 10 and replace them with NaN. Example: Input ...

14 years ago

Solved


Triangle Numbers
Triangle numbers are the sums of successive integers. So 6 is a triangle number because 6 = 1 + 2 + 3 which can be displa...

14 years ago

Solved


Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...

14 years ago

Solved


Determine if input is odd
Given the input n, return true if n is odd or false if n is even.

14 years ago

Solved


Make the vector [1 2 3 4 5 6 7 8 9 10]
In MATLAB, you create a vector by enclosing the elements in square brackets like so: x = [1 2 3 4] Commas are optional, s...

14 years ago

Solved


Find the sum of all the numbers of the input vector
Find the sum of all the numbers of the input vector x. Examples: Input x = [1 2 3 5] Output y is 11 Input x ...

14 years ago

Solved


Times 2 - START HERE
Try out this test problem first. Given the variable x as your input, multiply it by two and put the result in y. Examples:...

14 years ago

Answered
Puzzler: Quickly tell if two absolute indices (a,b) are four connected for n x m matrix.
function flag = isFourConnected(a,b,n,m) % 10 arithmetic operations by pair c = max(a,b); d = min(a,b); e = c - d...

14 years ago | 0

Submitted


N-dimensional histogram
Compute n-dimensional histogram

15 years ago | 4 downloads |

4.7 / 5

Answered
Create/deal big binary sparse matrices
m = 80000; n = 10000; p = 0.001; nel = m*n*p; rows = ceil(m*rand(1,nel)); cols = ceil(n*rand(1,nel)); A = sparse(...

15 years ago | 0

Answered
Defining points of a polygon for use in finding area of triangle.
For polygon (x1,y1) ... (xn,yn) Why not breaking up with respect to the first vertex: T1 = (x1,y1)(x2,y2)(x3,y3) T2 = (x1,y...

15 years ago | 1

Answered
Create/deal big binary sparse matrices
See my comment above. Instead of A=rand(t,n0)<p; Use sparse directly A = logical(sprand(t, n0, p)); % OR A...

15 years ago | 0

Answered
Multiply then sum elements of two matrices
I believe sum(A(:).*B(:)) would be faster than dot(...) if that matter.

15 years ago | 1

Answered
Counting Neighboring Cells
A=[1 0 1 1 0 1 1 0; 1 1 0 1 0 1 1 0] B = ones(3); B(2,2) = 0; conv2(A,B,'same')

15 years ago | 3

| accepted

Answered
Multinomial matrix
http://www.mathworks.com/matlabcentral/fileexchange/17818-all-permutations-of-integers-with-sum-criteria K=3 allVL1(K+...

15 years ago | 0

Answered
Simple Matlab Random Number Generation
To generate true uniform distribution, the correct method is not quite straightforward. I strongly recommend Roger Stafford's FE...

15 years ago | 6

Answered
d-column combinations of matrix A n by n
Another way is: any(A,2)

15 years ago | 1

| accepted

Answered
d-column combinations of matrix A n by n
I'm not ths is what you want: A=rand(10,5)>0.9 % Union of all columns of A logical(sum(A,2))

15 years ago | 0

Answered
normally random number generator with limited zone
This function will generate a normal distribution conditional by bounds: http://www.mathworks.com/matlabcentral/fileexchange/...

15 years ago | 2

| accepted

Answered
Histogram with overlapping bins
You might try this code using my mcolon function: <http://www.mathworks.com/matlabcentral/fileexchange/29854-multiple-colon> ...

15 years ago | 1

Answered
Search nx3 array row-wise for 2 equal elements
Here is a version that select groups of rows when *at least* two elements are common. % Data A = ceil(100*rand(1000,3)); ...

15 years ago | 0

Answered
Search nx3 array row-wise for 2 equal elements
I could not remove the two for-loops % Data A = ceil(50*rand(1000,3)); % Engine tic [m n] = size(A); groups = ce...

15 years ago | 0

Answered
vector to repeated matrix multiplication
v1 = [1 2 3] v2 = [4 5 6] A = [1 2; 3 4] v2(2,:) = -1 P=sum(bsxfun(@times,v1,v2),2) P(1)+P(2)*A % *Not* polyno...

15 years ago | 1

Answered
Quantify connectivity in a 3D matrix containing ones and zeros representing voids in a microstructure
If you have image processing toolbox, check out this function <http://www.mathworks.com/help/toolbox/images/ref/bwlabeln.html>

15 years ago | 0

| accepted

Answered
3D line approximation (spline)
It's called _spline fitting_. Please take a look at File Exchange, such as <http://www.mathworks.com/matlabcentral/fileexchange...

15 years ago | 3

Answered
Max. distance in a bidimensionnal vector
Here is something I wrote for my own use. The code is to prototype an algorithm which I did in C. S it is not speed optimized, b...

15 years ago | 1

Answered
Can I speed this code up, looking for similarity between two 3-d matrices.
The trick here is loop on A (small size) and vectorized on B % Test data B=rand(50,60,100); A=rand(2,3,4); %% Engine...

15 years ago | 0

| accepted

Answered
Element-wise multiplication where 'elements' are matrices and vectors
Reshape your matrices and vectors to appropriated form for: Matlab sparse matrix approach <http://www.mathworks.com/matlabcentr...

15 years ago | 1

Answered
griddata (averaging instead of interpolation)
As I understood you have 2D data _r_ depending of _theta_ and _z_ (and not 3D). theta = rand(100000,1)*2*pi; z = rand(10...

15 years ago | 0

| accepted

Answered
How to generate a vector with the required values
As Davide wrote, colon() operator will build the array by increment of the step (actually half incremental from both ends), and ...

15 years ago | 1

Load more