Risposto
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) ...

oltre 4 anni fa | 1

Risposto
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 (...

oltre 4 anni fa | 0

| accettato

Inviato


qsort
Sort data with user-supplied comparison function

oltre 4 anni fa | 6 download |

0.0 / 5

Risposto
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 ...

oltre 4 anni fa | 0

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

oltre 4 anni fa | 0

| accettato

Risposto
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*...

oltre 4 anni fa | 0

Risposto
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 ...

oltre 4 anni fa | 1

| accettato

Domanda


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...

oltre 4 anni fa | 1 risposta | 1

1

risposta

Domanda


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, ...

oltre 4 anni fa | 1 risposta | 0

1

risposta

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

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 0

Risposto
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...

oltre 4 anni fa | 1

Risposto
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...

oltre 4 anni fa | 1

Risposto
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,[...

oltre 4 anni fa | 1

| accettato

Risposto
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(...

oltre 4 anni fa | 0

Risposto
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...

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 0

Risposto
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==...

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 0

Risposto
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 ...

oltre 4 anni fa | 0

Risposto
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, [...

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 0

Risposto
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...

oltre 4 anni fa | 0

| accettato

Risposto
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])

oltre 4 anni fa | 1

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

oltre 4 anni fa | 0

| accettato

Risposto
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...

oltre 4 anni fa | 1

| accettato

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

oltre 4 anni fa | 0

Risposto
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...

oltre 4 anni fa | 1

| accettato

Carica altro