You could always thin the characters first, then artificially expand their skeletons by performing morphology. For expanding, morphological dilation is most suitable. As such, thin the characters...

A cheap way to do this would be to invert the image so that the object pixels are white instead of black, then performing a morphological closing on the image and removing those areas that fall...

If you want to extend the image so that original contents are in the middle, you can calculate the middle of the output image which is initialized to all 1s, then make sure you place the image so...

This will require a bit of mathematics to determine that analytically. By "90 degrees", I'm assuming you want to find the point on this 3D line that would be perpendicular to this line if you...

Another approach is to use hankel: >> n = 5; >> hankel(1:n, n:2*n-1) ans = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 ...

Your syntax for generating the 3D coordinates is right. Your call to surf is incorrect. What you actually need to do is separate x, y and z into three separate parameters: surf(x,y,z); When...

Assuming that each cell has two rows and a variable amount of columns where the first row is the ID and the second row is an attribute, I'd consolidate all of the cells into a single 2D matrix and...

Your call to zeros is incorrect. Looking at your code, D looks like a D x 2 array. However, your call of s = max(D,1) would actually generate another D x 2 array. By consulting the documentation...

Use bsxfun(MATLAB doc, Octave doc) and check to see if broadcasting the first slice is equal across all slices with a call to all(MATLAB doc, Octave doc): B = bsxfun(@eq, A, A(:,:,1)); result =...

Use ischar. This checks to see if an input into this function is a character array, and reports true if it is and false otherwise. Take note that a single character is also a character array......

Use the third output of unique when examining A over the rows and with the 'stable' flag, then use this as input into accumarray. The third output assigns a unique ID for each unique occurrence of...

A solution in MATLAB (perhaps inelegant) could be something like this: N = 10; k = 4; out = zeros(1,k); vec = 1 : N; for idx = 1 : k ind = randi(numel(vec), 1); left = max(ind-1, 1);...

Here's one approach with kron and reshape: A = 0:N-2; B = reshape(kron(A, ones(M, N-1)), M, N-1, []); We use kron to produce M x (N-1) 2D matrices that are stacked for as many elements as there...

I would load each .mat file in sequence and put each of the corresponding calories as a separate field being all combined into a single struct for you to access. Given the directory of where these...

Simple. First make a handle to the function where the only input is the cell array: h = @(x) D(x, a, b); Here, x would be a cell from the cell array. Also, I'm going to assume that a and b are...

interp2 may be of use here. Use the data as key points, then create a finer grid of points that span the same width and height and interpolate in between the key points. Something like...

In terms of calculating the histogram, the computation of the frequency per intensity is correct though there is a slight error... more on that later. Also, I would personally avoid using loops...

No, there is currently no way to change the default numeric type to float / single. See these informative posts on MathWorks forums:...

If I am interpreting what you want correctly, for each unique 3D position in this matrix of 7 x 4 x 24, you want to be sure that we randomly sample from one out of the 10 stacks that share the...

You can approach this in one of two ways (à la Luis Mendo): Approach #1 - Deterministic If you know that you need exactly 500 ones and 500 zeroes for each time you create this vector, you can...

You can approach this in a linear interpolation viewpoint. Assuming that there are no consecutive negative numbers in z, you can do this with interp1: %// Define your data z=...

This goes against my policy in answering questions without any effort made by the question poser, but this seems like an interesting question, so I'll make an exception. First, split up each of...

One simple suggestion I have is to detect the gradient and determine the orientation of an edge point. If the orientation is either -180 degrees or 180 degrees, set this to be the output. Use...

How about an approach using strings? This is certainly not as fast as Luis Mendo's method where you work directly with the numerical array, but it's thinking a bit outside of the box. The basis...

For canonical purposes, here's how you'd do it via loops. This is a bit inefficient since you're mutating the array at each iteration, but it's really simple to read. Given that your two matrices...