Answered
Create vector with unique values
% I'm sure there is no repetition but the set of values is not random r = 1+randperm(5000)/5000; % check all(r>=1 & r<=2) ...

4 years ago | 1

Answered
Interp1 Function gives back NaN in second to last datapoint
MATLAB interp1 by default gives NaN for query points falling outside your source points (first and last). Use 'extrap' option (...

4 years ago | 0

| accepted

Submitted


qsort
Sort data with user-supplied comparison function

4 years ago | 1 download |

0.0 / 5

Answered
multiplying matrix by a vector on an element by element basis using for loops
To be able to compute A*B; You need B is column (vector): the number of rows of B much match the number of rows of A, 5 in this ...

4 years ago | 0

Answered
How to sort eigenvalues when performing generalized nyquist criterion on 2x2 matrix?
Replace statement E1(:,k) = eig(Z_nyquist1); by % track eigen values ----------------------------------------------- ...

4 years ago | 0

| accepted

Answered
null() fails for a symbolic numeric 5x5 matrix
Just a wild guess but when you call null(A) with symbolic matrix, MATLAB tries to solve for lambda the equation det(A - lambda*...

4 years ago | 0

Answered
Is cell2mat supposed to support non-plaid cell partitioning? If not, why not?
But this one works Ctlarge={rand(1,2) rand(1,1) rand(1,0); rand(3,1) rand(3,2) rand(3,0)} cell2mat(Ctlarge) You can edit the ...

4 years ago | 1

| accepted

Question


why wrapping with anonymous function speeds up?
I try to understand the rational behind this result. When I wrap a function within an anonymmous function, it runs almost 10 tim...

4 years ago | 1 answer | 1

1

answer

Question


Profiler: time spend at while END statement
I run a profiler on my code, and it is reported a significant amount of time is at the "end" statement of a while loop (here i, ...

4 years ago | 1 answer | 0

1

answer

Answered
split the matrix into two
A = randi(10,3,6) B = A(:,1:2:end) C = A(:,2:2:end)

4 years ago | 0

| accepted

Answered
How to find 5 consecutive values above threshold within a certain window?
A = [6 7 8 8 8 7 6 7 6 2 7 8 9 3 3 4 6 7 8 9] win = 5; threshold=5; maxreject=3; % Pad NaNs so that the length is multiple...

4 years ago | 0

Answered
How to have Matlab create a random matrix that is fullrow rank?
Here is a way to generate finite condition number matrxix , meaning stronger than full rank, and it must give a full rank (unles...

4 years ago | 1

Answered
Generalized sorting function with user defined (template-)criterion
AFAIK there is no such thing in stock function in MATLAB, the main reason is MATLAB function calling mechanism will kill the per...

4 years ago | 1

Answered
How to reshape an M x (aN) matrix into a (aM) x (N) matrix in MATLAB?
Use permute m = 3; n = 2; a = 4; A = reshape(zeros(m,n)+reshape(1:a,[1 1 a]),[m n*a]); A B = reshape(permute(reshape(A,[...

4 years ago | 1

| accepted

Answered
Determining relative angular orientation of vectors
No need to call costly trigonometric functions % Direction of incidence Ray (normalized) Rayi = randn(2,1); Rayi = Rayi/norm(...

4 years ago | 0

Answered
I need to find the length of the longest strictly increasing subsequence array from a given array I just need a tip to start. Any type of help will be appreciated
Dynamic programming, it may take longtime for large array a = [0,1,2,3,4,1,2,0,4,5,8,9,11,11,4,4,9,9]; i = longestsubseq_helpe...

4 years ago | 0

| accepted

Answered
How to solve the following type of equation that includes summation in matlab?
Assuming H_m and t_m are stored in (1 x M )arrays % Dummy test data M = 10; H = rand(1,M); t = rand(1,M); P = sum( abs(H...

4 years ago | 0

| accepted

Answered
I need to find the length of the longest strictly increasing subsequence array from a given array I just need a tip to start. Any type of help will be appreciated
a=rand(1,1000000); idx=find(diff([false diff(a)>0 false])); [lgtmax, j]=max(idx(2:2:end)-idx(1:2:end)); longestincreasedsub...

4 years ago | 0

Answered
Sort vector A according to vector B
A = [0.9; 0.2; 0.4; 0.2; 0.3; 0.4; 0.7; 0.4; 0.1; 0.8; 0; 0; 0; 0]; B = [0; 0; 1; 1; 1; 1; 0; 0; 0; 0; 0; 0; 0; 0]; Ais0=A==...

4 years ago | 0

| accepted

Answered
How to find the index of first and last nonzero elements in each column?
Some C-mex solution for speed: https://fr.mathworks.com/matlabcentral/fileexchange/24641-vectorized-find-with-first-option?s_ti...

4 years ago | 0

Answered
How to find the index of first and last nonzero elements in each column?
Let you do conversion to linear index A=[0 0 0 0 0 0 0 0 1 0 4 8 2 0 ...

4 years ago | 0

Answered
Symbolic multidimensional arrays with changable dimension
p = [1 2 3 4]; c = [1 2 3 4; 1 2 3 4; 1 2 3 4; 1 2 3 4]; n=3; M = p(:); % EDIT, bug fix for k=1:n-1 cc = reshape(c, [...

4 years ago | 0

| accepted

Answered
What function in MATLAB for calculating the value of inverse standard normal distribution function?
There is no sense to substract 1 to *inverse* CPF, which take argument value in (0,1) and maps to (-Inf,Inf). It only makes sens...

4 years ago | 0

Answered
Making a spherical cap using equations of sphere
phi=linspace(pi/2,pi/6,30); % the cap end is determined by pi/6 change accordinglt theta=linspace(0,2*pi,120); r=3; [PHI,TH...

4 years ago | 0

| accepted

Answered
Converting location of a 2x3 vector into a matrix with value 1
a = [1,3;2,4;7,8]; % assumed there is no repeated indexes A = accumarray(a,1,[10,10])

4 years ago | 1

Answered
Gaussian fiiting of a truncated data
Remove the data above 1.96 and fit with the rest.

4 years ago | 0

| accepted

Answered
How do I generate a random number between two numbers with using a distribution
% define the siscrete value and their relative pdf xval=(-10:10); p=exp(-(xval/5).^2); % Gaussian function, triangular whateve...

4 years ago | 1

| accepted

Answered
How do I create this full diagonal matrix
n = 5; A = n-abs((1:n)'-(1:n))

4 years ago | 0

Answered
How to partially validate arguments?
I believe the issue is that your argument isn't self consistent. When you use syntax such as optional_positional = 1 That mea...

4 years ago | 1

| accepted

Load more