A résolu


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 ...

plus de 14 ans il y a

A résolu


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...

plus de 14 ans il y a

A résolu


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...

plus de 14 ans il y a

A résolu


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

plus de 14 ans il y a

A résolu


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...

plus de 14 ans il y a

A résolu


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 ...

plus de 14 ans il y a

A résolu


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:...

plus de 14 ans il y a

Réponse apportée
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...

presque 15 ans il y a | 0

A soumis


N-dimensional histogram
Compute n-dimensional histogram

presque 15 ans il y a | 1 téléchargement |

4.7 / 5

Réponse apportée
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(...

plus de 15 ans il y a | 0

Réponse apportée
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...

plus de 15 ans il y a | 1

Réponse apportée
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...

plus de 15 ans il y a | 0

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

plus de 15 ans il y a | 1

Réponse apportée
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')

plus de 15 ans il y a | 3

| A accepté

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

plus de 15 ans il y a | 0

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

plus de 15 ans il y a | 6

Réponse apportée
d-column combinations of matrix A n by n
Another way is: any(A,2)

plus de 15 ans il y a | 1

| A accepté

Réponse apportée
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))

plus de 15 ans il y a | 0

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

plus de 15 ans il y a | 2

| A accepté

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

plus de 15 ans il y a | 1

Réponse apportée
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)); ...

plus de 15 ans il y a | 0

Réponse apportée
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...

plus de 15 ans il y a | 0

Réponse apportée
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...

plus de 15 ans il y a | 1

Réponse apportée
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>

plus de 15 ans il y a | 0

| A accepté

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

plus de 15 ans il y a | 3

Réponse apportée
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...

plus de 15 ans il y a | 1

Réponse apportée
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...

plus de 15 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 15 ans il y a | 1

Réponse apportée
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...

plus de 15 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 15 ans il y a | 1

Charger plus