Answered
How to split an array of integers into arrays of varying lengths where all the elements are close in value to each other?
ind = [2 3 4 998 999] lgt = diff(find(diff([-Inf, ind, Inf])>=5)); gind = mat2cell(ind,1,lgt); results: >> gin...

7 years ago | 0

| accepted

Answered
A*A'=C
One solution can be found by using SVD >> C = [2/3 -1/3 -1/3;-1/3 2/3 -1/3;-1/3 -1/3 2/3] C = 0.6667 -0.3333 -0.3...

7 years ago | 0

| accepted

Answered
Decomposing a Transformation Matrix
Translation vector is T(1:3,4); Rotation matrix is T(1:3,1:3). If you want to decompose in rotation on axis, there are many co...

7 years ago | 0

Answered
how can i valid if the polygon i have received , X=[x1,x2,x3,x4] Y =[y1,y2,y3,y4] has no internal angle bigger than 180
That simply means the polygonal is convex. To check it K = convhull(x,y); isequal([1:length(x) 1]',K) || isequal([1 length(x):...

7 years ago | 0

| accepted

Answered
problem with interp1
[x,i] = unique(log10(dlrg)) plrg = interp1(x,plrg(i),log10(dnew),'linear','extrap');

7 years ago | 1

Answered
Rotating X and Y coordinates with a certain angle.
rotcoord=coordT*R'

7 years ago | 0

| accepted

Answered
Split array into some equal and some unequal length sections
a = [1:41683]' n = size(a,1); blk = 60; lgt = ones(1,floor(n/blk))*blk; r = n-sum(lgt); if (r > 0) lgt(end+1) = r; b = m...

7 years ago | 0

Answered
Find the number of rows and column of non-zero number(1st)
[c,r] = find(Mat.',1,'first'); a = [r,c]

7 years ago | 1

| accepted

Answered
All index values expect certain indices
A = [5 6 7 8]; x{1} = [1]; x{2} = [1 2]; x{3} = [2 3 4]; c = cellfun(@(i) A(setdiff(1:end,i)), x, 'unif', 0) c{:} That g...

7 years ago | 1

| accepted

Answered
How to check the number of ones from certain row to the 1st row?
>> squeeze(sum(t(1:7,:,:)==1,2)) ans = 1 0 0 0 0 0 0 0 0 0 0 0 ...

7 years ago | 2

| accepted

Answered
Checking if a matrix is symmetric
disp(isequal(A,A.'))

7 years ago | 1

| accepted

Answered
Alternative for interp1 for fast computation
range = 0:0.1:6; data = log(tanh(abs(range))) edges = [-Inf, 0.5*(range(1:end-1)+range(2:end)), Inf]; % this is done once ...

7 years ago | 0

Answered
How to send specific conditions to lsqcurvefit?
Change you variable b to c = [b(1), b(2)-b(1)] meaning b = [c(1), c(1)+c(2)] Make lsqcurvefit works on c, with the constrai...

7 years ago | 0

Answered
Get range of integer values from adjacent column elements (integers) for multiple rows.
This code n = 10; seg = 2; b = mod(0:n-1,2*seg)<seg; A = repmat(1-b,n,1) Gives this output: A = 0 0 1 ...

7 years ago | 1

| accepted

Answered
Finding rows in matrix containing numbers from vector
find(sum(ismember(M,A),2)>=2)

7 years ago | 0

| accepted

Answered
Rotate the 3D point data about Z axis , and // OX OY
xyz=load('data.txt'); xyzc = mean(xyz,1); xyzr = xyz - xyzc; [~,~,V] = svd(xyzr,0); % Rotate 90°: so that the long size // t...

7 years ago | 0

| accepted

Answered
How to effectively reorder data
Solve it as Traveling SalesMan PB: Use this FEX contorno = readtable('HJ_00-01.xlsx'); contx = table2array(contorno(:,1)); ...

7 years ago | 2

| accepted

Answered
speed up run time of mldivide function.
You might want to use iterative method.

7 years ago | 1

Answered
How to find out how many colums are in matrix?
if ischar(filename) % you select 1 file something1 else % your filename is cell of char/string % I have 2 selected files ...

7 years ago | 0

| accepted

Answered
Find unique permutations of a matrix
N = 6; p = factor(N); q = length(p); b = dec2bin(0:2^q-1,q)-'0'; m = unique(prod(b.*p+(1-b),2)); n = N./m; C = num2cell(pe...

7 years ago | 1

Answered
How can i make it more simple? with n=20000 it takes to much time to solve.I need to simulate how many random values of a 20000x1 matrix (with average of 4 and 0<x<26.77) exceed 14.45.
Use this FEX ex = 4; % expected mean lo = 0; hi = 26.77; n = 20000; x = zeros(1,n); % randfixedsum can't handle correctl...

7 years ago | 2

| accepted

Answered
partial derivative of conv2(I,w) with respect to the w's elements?
Use KRON and CONVMTX to transform CONV in wrt either argument a linear operator, whose matrix is then the partial derivative.

7 years ago | 1

| accepted

Answered
Finding extreme points on the major and minor axis of an ellipse from the equation
You can use the function EllAlg2Geo in this FEX or attached here L = rand(2); A=L'*L; b=rand(2,1); c = -rand; [radii, U, ...

7 years ago | 1

Answered
How can I get a 'random index' of unique elements in a matrix rather than first/last index ?
p = randperm(length(M)); [C,ia,~] = unique(M(p)); ia = p(ia)

7 years ago | 1

| accepted

Answered
combine two matrices to get another matrix of same size
>> a=[1,2;3,4]; >> b=[5,6;7,8]; >> a*10+b ans = 15 26 37 48

7 years ago | 2

Answered
how do i get the higher values into the bins
[~, discrete_x] = histc(x, [edges Inf]);

7 years ago | 1

Answered
if i have a matrix a=[1 2 3;2 3 3; 2 3 4] i would want to find if the maximum in each column is appearing more than once.plz help.
>> a=[1 2 3;2 3 3; 2 3 4] a = 1 2 3 2 3 3 2 3 4 >> [imax,jmax] = find(a==max(a...

7 years ago | 0

Answered
In an assignment A(:) = B, the number of elements in A and B must be the same.
function[dy_dx] = RK4(x,y) %%x = 0:0.1:1; <- this line is wrong, x is input argument don't shadow it y(1) = 1; dy_dx = (1 + ...

7 years ago | 0

Load more