Answered
select numbers based on different probabiltiies
select = rand < 1e-6

7 years ago | 1

| accepted

Answered
How i Calculate the average number of even numbers in an array?
a = [1.3700 1.2200 2.2000 2.2800]; ac = round(a*100); mean(ac(mod(ac,2)==0))/100 result ans = 1.9000

7 years ago | 0

| accepted

Answered
what is non-local total variation regularizarition (NLTV)?
That means the regularization of the image I(x,y) is of the form integral of lambda(x,y) | grad I (x,y) | dx*dy. lambda(x,y) i...

7 years ago | 0

Answered
Using the cubic spline code below, I need to extract the value found for x = 3.5. How do I call this value?
Run this after your code >> tempx = 3.5 tempx = 3.5000 >> [~,i] = histc(tempx,x); >> a(i) + b(i)*(tempx-x(i))+c(...

7 years ago | 0

| accepted

Answered
Which mldivide ('\') function is better
Use pseudo inverse PINV to get more stable solution. Never use "\" on nearly singular matrix. You are happy with 2008 is just pu...

7 years ago | 0

| accepted

Answered
Is "ismultithreaded" function exist?
Not that I'm aware of, in any case they will give out such information since they (TMW) have a habit to consider speed optimizat...

7 years ago | 0

Answered
FFT seems to be not calculating Nyquist component?
Change A*sin(2*pi*Fs/2*t) to A*cos(2*pi*Fs/2*t) Or alternativey you must put cos expression in the imaginary part of your...

7 years ago | 1

| accepted

Answered
Structure array slower than loose variables
Yes acessing field names is slow., so try to avoid doing it intensively.

7 years ago | 1

| accepted

Answered
How to solve a complex-valued equation
So your equation is of the form a / (g - x)^2 = k* x Just multiply by (g - x)^2 in both sides, you'll get a = (g - x)^2 * k* ...

7 years ago | 1

| accepted

Answered
For Loop to concatenate Matrix Product
A_All = []; A_0toAll = []; C_i = 1; for i=1:5 T_i = [i+2 i+3 i+4 i+5; i+3 i+4 i+5 i+6; i+4 i+...

7 years ago | 0

| accepted

Answered
Force slope and return intercept value (assuming a non-zero intercept)
m = WhatYouWantItToBe k = mean(log10(y)-m*log10(x))

7 years ago | 1

| accepted

Answered
get vector from a matrix ith row or column based on given dimension
c = repmat({':'},1,ndims(A)); c{dim}=i; A(c{:})

7 years ago | 2

| accepted

Answered
Finding PDF for difference of two PDFs
For 2 dependent variables A and B, the pdf of A+B is pdf(A+B) = pdf(A) * pdf(B) where "*" is a continuous convolution operator...

7 years ago | 0

Answered
Specified number of ones in the matrix (column and row)
From an idea by Akira Agata n = 10; % Matrix dimension k = 4; % row/column sum target of 1s r = [ones(1,k) zeros(1,n-k)]; ...

7 years ago | 2

Answered
Using a vector as an index to a matrix
[m,n,p] = size(A); [I,J] = ndgrid(1:m,1:n); C = A(sub2ind([m,n,p],I,J,b(I)))

7 years ago | 0

| accepted

Answered
Low Level Graphics Error
After crash you migh run opengl hardware opengl('save','hardware') to restore value. I systematically have opengl crash whe...

7 years ago | 0

| accepted

Answered
Finding rows of matrix A that do not overlap with any rows in Matrix B (without using for or while loop)
Assuming A and B are column-sorted for all rows A= [ 0 50; 200 250; 300 350; 400 450]; B=[50 200; 200 300; 300 400]; BB=res...

7 years ago | 0

| accepted

Answered
Need help with solving system of ODEs in Matlab
y=zeros(m, N+1); % numerical approx. vector I think it should be y=zeros(N+1,m); % numerical approx. vector Those things ...

7 years ago | 0

| accepted

Answered
preallocate array without initializing
MEX can do that, use for example this utility

7 years ago | 1

Answered
How to change matrix numbers positions
X(randperm(numel(X))) = X

7 years ago | 0

Answered
Difference between the individual rows of B and all the rows of A.
DIF = zeros(size(A,1),size(B,1)) for k=1:size(B,1) DIF(:,k)=sqrt((A(:,1)-B(k,1)).^2+(A(:,2)-B(k,2)).^2+(A(:,3)-B(k,3)).^2)...

7 years ago | 1

| accepted

Answered
Project 3D points onto a 2D plane with least overlap
Assuming your data points is store in (n x 3) array xyz xyzc = mean(xyz,1); [~,~,V] = svd(xyz - xyzc,0); xy2d = xyz*V(:,1:2);...

7 years ago | 1

Answered
Finding PDF for difference of two PDFs
Not sure if it helps but the green area is { (x:y) : 0 <= y <= min(p1(x),p2(x)) }

7 years ago | 0

Answered
randsample([0 1],1,true,[1 - p p]) ..... with p as a vector?
Assuming yoy have p in a vector r = rand(size(p))<p

7 years ago | 0

Answered
How can I efficiently (with no loops) compute the mean of each column in a matrix, taking different elements from each column?
M = [ 1 2 3 4 5; ... 6 7 8 9 10; ... 11 12 13 14 15]; idx = [ 1 2 3 2 1; ... 2 3 3 3 3]; m = si...

7 years ago | 1

| accepted

Answered
How can I efficiently (with no loops) compute the mean of each column in a matrix, taking different elements from each column?
M = [ 1 2 3 4 5; ... 6 7 8 9 10; ... 11 12 13 14 15]; idx = [ 1 2 3 2 1; ... 2 3 3 3 3]; [m...

7 years ago | 0

Answered
Generate all possible combinations
A = [1;2] B = [3;4] C = [5;6] D = [7;8] L = {A,B,C,D}; n = length(L); [L{:}] = ndgrid(L{end:-1:1}); L = cat(n+1,L{:}); ...

7 years ago | 2

| accepted

Answered
Generate All Possible combinations
A = [2;4;6] B = [1;3;5] [AA,BB] = meshgrid(A,B); C = [AA(:),BB(:)] ans = 2 1 2 3 2 5 ...

7 years ago | 0

| accepted

Answered
How can I compute all the possible differences of the vectors in a matrix?
>> A = [1,2,3; 4,0,1; 2,3,5; 6,0,1]; >> r2 = nchoosek(1:size(A,1),2) r2 = 1 2 1...

7 years ago | 0

Load more