Answered
How we can convert negative float value into binary in matlab? Is there any direct command for this?
This is a function I wrote for my own use long ago. Perhaps you can make use of it or it can give you some ideas. It converts ...

13 years ago | 0

| accepted

Answered
How to vectorize this code?
Your outer two for-loops can be vectorized, but the innermost one which involves the iteration process cannot - at least as far ...

13 years ago | 1

| accepted

Answered
Alternate to the circshift function in a 3d matix for an agent based model
If a circular shift by +1 done with indexing is significantly faster than your 'circshift' operations, then you can do the equiv...

13 years ago | 0

| accepted

Answered
normalizing constant of a column and inverse matrix understanding
Yes, by the term "normalizing constant" in this context is clearly meant a constant such that when it is multiplied by the vecto...

13 years ago | 0

Answered
changing a value in an array with matrix indices
You need to replace i_i(a_a(2,1) a_a(2,2) a_a(2,3))=1 with i_i([a_a(2,1),a_a(2,2),a_a(2,3)]) = 1; (I assume you wa...

13 years ago | 0

| accepted

Answered
finding principal axis and moments of inertia tensor using eig function
*"Is it cos(Axes(:,1)), cos(Axes(:,2)), cos(Axes(:,3)??"* No, the components of the eigenvectors themselves, Axes(:,1)), Axes...

13 years ago | 1

| accepted

Answered
finding values and ignoring repeats
[t,ir] = min(distvec); [m,ic] = min(t); I = [ir(ic),ic]; I has the indices of the minimum value in 'distvec' and 'm' is ...

13 years ago | 0

| accepted

Answered
Replacing duplicates in a vector of required length
If you are not concerned with duplicates in 'du', here is a method which only calls on 'randfixedsum' once, but adjusts an offse...

13 years ago | 0

| accepted

Answered
Replacing duplicates in a vector of required length
I ran your computation du=round(randfixedsum(14,1,2880,120,300)); several thousand times and found that the odds of getti...

13 years ago | 0

Answered
extracting subsequences of binary string
Here is a slightly shorter version: n = 20; d = 4; f2 = cumsum([0,floor((n-1:-1:d-1)/(d-1))]); f1 = f2(1:end-1)+1; ...

13 years ago | 0

Answered
extracting subsequences of binary string
n = 20; d = 4; c = zeros(sum([1,floor((d:n-1)/(d-1))]),d); % Allocate space for c j = 0; for k = 1:n-d+1 r = 1; w...

13 years ago | 0

Answered
Find maximum number of consecutive negative values
If you want the code completely vectorized, let x be your matrix and do this: [m,n] = size(x); p = double([0;reshape([x;ze...

13 years ago | 0

Answered
Cross Product and Vector Multiplication
C = [ cross(A',B(:,1)) , cross(A',B(:,2)) , cross(A',B(:,3)) ]\(D');

13 years ago | 1

| accepted

Answered
How can I generate an array that satisfies a given number of repetitions and unique values
t = accumarray(cumsum([1,x]),1); z = y(cumsum(t(1:end-1)));

13 years ago | 0

Answered
How to solve this equation which contains the complementary error function?
As Walter has pointed out, it is surely not possible for 'solve' to find an explicit solution for t in terms of the other variab...

13 years ago | 0

| accepted

Answered
Create zeros in matrix size, but not 1. column and row, or last column and row
v(2:3,2:3) = 0; Note: This method only works for rectangular regions. For other shapes you need to use linear indexing.

13 years ago | 2

| accepted

Answered
Creating a new matrix in a loop from a pre-determined matrix
Your for-loop isn't right. The 'numel' will give you too many indices. It should be n = size(x,1); a = zeros(n,1); for...

13 years ago | 0

Answered
Finding the surface area of a 3-D plot?
To get the surface area you need to first determine the surface normal for each point in your mesh of x-y points, as you would t...

13 years ago | 2

| accepted

Answered
I am trying to find the cumulative distribution function of the standard normal. I have the value that I will be using the cdf to analyze but cannot figure out the functions to go with it. Can anyone help me find the correct functions/code?
Use matlab's 'erfc' function in place of 'normcdf' if you don't have the Statistics Toolbox according to the formula: normcd...

13 years ago | 0

| accepted

Answered
building all such vectors?
This is a problem in combinations, not permutations, and can be performed using matlab's 'nchoosek' function. Note that the num...

13 years ago | 2

| accepted

Answered
CODE FOR VECTOR ALGEBRA DIHEDRAL ANGLE CALCULATION
Your notation "(n1.n2) / n1.|n2|" is confusing. If by this you mean the dot product of n1 and n2 divided by the product of thei...

13 years ago | 0

Answered
How can I compute the volume under a three class ROC surface
Based on what I see in your link, your ROC volume can be subdividing into individual five-faced polyhedrons each of whose base i...

13 years ago | 0

| accepted

Answered
What is the most compact way to update an index vector out of a cube?
knext = D(y+ny*((r-1)+nr*(k-1)));

13 years ago | 1

Answered
How to reduce an existing matrix
M = M(10:10:end,10:10:end);

13 years ago | 0

Answered
How to reduce an existing matrix
I think you mean reduce it to (1880x1880). M = M(1:end-5,1:end-5);

13 years ago | 1

| accepted

Answered
Error in my code.....
The error message is telling you what the problem is. The 'histo' function has received an input 'I' with zeros in it, and is a...

13 years ago | 1

Answered
Unable to solve symbolic equation> Error Warning: Explicit solution could not be found. > In solve at 81
Any solution to your equation must be a root of the following quartic equation in p: (a1*a2)^2*p^4-2*a1*a2*(c-1)*(c-3)*p^2+4...

13 years ago | 0

Answered
How to obtain Barycentric Coordinates of a point in a triangle?
I've read over the 'cartesianToBarycentric' documentation. Here's a couple of observations. a) Your matrix T does not contain ...

13 years ago | 1

| accepted

Answered
How to obtain Barycentric Coordinates of a point in a triangle?
I am not familiar with the use of the 'cartesianToBarycentric' function, but I do know how to find the barycentric coordinates o...

13 years ago | 2

Answered
How to calculate the angular error
Apparently you have two 3D vectors, each of unit magnitude, el and ee, and you wish to find the angle between them. One formula...

13 years ago | 0

| accepted

Load more