Answered
How can I assign values to elements with same index from multiple cells?
Matlab is not clever enough to expand inner indexing into outer cells (plus there's no guarantee it would work, some cells may n...

11 years ago | 1

| accepted

Solved


Is It a Snake?
Given an m-by-n matrix, return true if the elements of the matrix are a connected "snake" shape from 1 to m*n. Otherwise return ...

11 years ago

Solved


prime to each other
Given two integers n1, n2 greater than 1, find out if they are prime to each other.

11 years ago

Solved


Sum of elements of array
Sum of elements of array

11 years ago

Answered
How to filter an array?
It's very simple: diff([0; A]) == 1 simply detects all transition from 0 to 1 and return them as 1.

11 years ago | 1

| accepted

Answered
Please help regarding the vectorization of the code. Thanks
Learn to use <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> and outer product ( <http://www.mathworks.com/help/...

11 years ago | 0

Answered
Error using .* matrix dimensions must agree
It appears to me that there is an obvious bug. You have: ... %% Max plotdata = Max; A=sortrows([Dir,plotdata]); %...

11 years ago | 0

| accepted

Answered
how to solve Ring topology?
Here is a simple way to generate your triplets (they're not pairs!): triplets = @(v) [circshift(v, [0 1]); v; circshift(v, ...

11 years ago | 0

| accepted

Answered
calculate the averages and standard deviations of massive matrix
Well, since the smaller matrices are generating by taking the mean of blocks of the larger matrix, the mean of the whole matrice...

11 years ago | 0

Answered
how to resolve error in this program
The problem is fairly simple. Since you never declare J, it gets resized on iterations of your inner loop whenever |x1| or |y1| ...

11 years ago | 0

Answered
Sum elements in a column where there are matching values in an adjacent column?
Since |accumarray| appears to be doing some weird reordering, I'm not sure it can be use to do what you want. No matter, a loop ...

11 years ago | 2

Answered
Combing Algorithm: Finding Unique Equaltiy between Vectors of Different Sizes Using Ranges
Despite your claim, it's not entirely clear what you want. Particularly I've not understood at all what your truth vectors corre...

11 years ago | 0

Answered
counting and merging in array
First one is simply <http://www.mathworks.com/help/releases/R2015b/matlab/ref/sort.html sorting>: x = {0:2:6, [1 2]}; so...

11 years ago | 0

Answered
Find sum of matrices, of different sizes, in a cell
It's arguable that |cellfun| is not a loop, but here is one way to do it C{1}=magic(3); C{2}=magic(5); total = cumsum...

11 years ago | 1

| accepted

Answered
Identifying an image type or format
The more information you give, the easier it makes it to try to identify the image type. What is used to capture the image (what...

11 years ago | 0

Answered
How to take the mean of hyperspectral image of size (1312*959*31) and plot its spectrum in matlab 7.0 after masking the specific part ?
Learn to use matrix operations instead of loops. Your code will be a lot faster and much easier to read. For example, your first...

11 years ago | 0

| accepted

Solved


Find elements of set A those are not in set B
Given two sets of data A and B. Find elements of A those are not in set B. ...

11 years ago

Solved


FInd an Area of a Polygon
Consider 2-D geometry and assume that the points are given in form of rows of a matrix. Find an area of polygon enclosed by the ...

11 years ago

Solved


sparse_matrix
You convert a vector to a sparse matrix. for example *x* =[1 2 3]; output will be *y* = [1 0 0 ...

11 years ago

Answered
Vectorization of nested for loops
Assuming |Vm| is a column vector (if not, change it so it is) and |BmVa| is a scalar: assert(iscolumn(Vm), 'Vm must be a co...

11 years ago | 0

| accepted

Answered
Why does my anonymous function have an error?
It's difficult to answer in great details with so little information, but either |x| has less than 23 elements when your program...

11 years ago | 0

| accepted

Answered
how to add ; in real time matrix in matlab?
Assuming you meant that the original matrix is 100x30 (not 100x3 which makes no sense), you could simply paste it as is and resh...

11 years ago | 0

Answered
How to search for a previous element that is equal in prior loop iteration
For small arrays, it does not matter but this is likely to be more efficient than harjeet's answer for large arrays: a = [1...

11 years ago | 1

Answered
Returning row and column number
Use |strcmp| (or |strcmpi| for case insensitive comparison) to get a logical array of strings that match. *IF* you really need t...

11 years ago | 1

Answered
Add the rows of a Matrix until a certain value.
First, a much better way to implement your vector algorithm is to use <http://www.mathworks.com/help/matlab/ref/cumsum.html |cum...

11 years ago | 0

| accepted

Answered
using structures and for loops
_"P contains the same values for P(1).soleus, P(2).soleus, P(3).soleus, ...P(10).soleus"_. Well, yes it would: P(idx).(name...

11 years ago | 0

Answered
What exactly represents a voxel after loading an image into an array/matrix?
It all depends what sort of image you're loading. I'm not familiar with 3d image formats at all but the image formats I'm famili...

11 years ago | 0

Answered
How to concatenate array with delimeter?
This looks to be related to your <http://www.mathworks.com/matlabcentral/answers/261249-how-can-i-do-this-5-6-7-8-23-24-39-40-55...

11 years ago | 0

| accepted

Answered
How can I concatenate arrays in loop ?
It looks like your |X| and |Y| are row vectors of size |[1, K1]| (inferred from the line |Helix = [X_rotate(1:K1) ; Y_rotate(1:...

11 years ago | 1

| accepted

Load more