Answered

Best Practice: Many Functions relying on Global Variables?

May be a little cumbersome but for serious application and when I'm not lazy, I define a subclass UniversalParameterClass of Sin...

Best Practice: Many Functions relying on Global Variables?

May be a little cumbersome but for serious application and when I'm not lazy, I define a subclass UniversalParameterClass of Sin...

17 dagar ago | 1

Answered

Find a number and range of group of the same number

A= [1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 1 1 2 2 1 1 3 3 3 3 3 1 1 1 2 2 2 ]; [u,~,G]=unique(A); n = length(u); for g=1:n i = f...

Find a number and range of group of the same number

A= [1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 1 1 2 2 1 1 3 3 3 3 3 1 1 1 2 2 2 ]; [u,~,G]=unique(A); n = length(u); for g=1:n i = f...

18 dagar ago | 0

Answered

How to fit a data to a model without using Statistical Toolbox?

Polynomial fits can be done with linear algebra, no fminsearch is required, but yeah clearly the model cannot fit data with thre...

How to fit a data to a model without using Statistical Toolbox?

Polynomial fits can be done with linear algebra, no fminsearch is required, but yeah clearly the model cannot fit data with thre...

18 dagar ago | 2

Answered

Null space solutions in the presence of noise

You can call [x_lsq ,a] = eigs(@(x) (S'*S)\x, size(S,2), 1, 'smallestabs') where S is your (sparse) matrix sqrt(a) is the sma...

Null space solutions in the presence of noise

You can call [x_lsq ,a] = eigs(@(x) (S'*S)\x, size(S,2), 1, 'smallestabs') where S is your (sparse) matrix sqrt(a) is the sma...

18 dagar ago | 0

Answered

problem with scatteredInterpolant: are there any limits?

You'll have problem anyway since your data is not centered and especially not normalize. x range is 130 and y range is 1155688,...

problem with scatteredInterpolant: are there any limits?

You'll have problem anyway since your data is not centered and especially not normalize. x range is 130 and y range is 1155688,...

18 dagar ago | 1

Answered

Solving an implicit equation in matlab

D=1/(V-b) is a root of fifth order polynomial, where the coefficients depend on P, T, etc... It looks like it is small non-line...

Solving an implicit equation in matlab

D=1/(V-b) is a root of fifth order polynomial, where the coefficients depend on P, T, etc... It looks like it is small non-line...

18 dagar ago | 0

Answered

Solving an implicit equation in matlab

The numerical answer is -0.284179329144572 format long -(17211847986098922057056496272843303410021431145154622943954950247403...

Solving an implicit equation in matlab

The numerical answer is -0.284179329144572 format long -(17211847986098922057056496272843303410021431145154622943954950247403...

18 dagar ago | 0

Answered

Creating curved alpha hull, similar to R-package

Just plot the boundary as concave. Some time it doesn't work since the vert returned are not in order, I don't know why and coul...

Creating curved alpha hull, similar to R-package

Just plot the boundary as concave. Some time it doesn't work since the vert returned are not in order, I don't know why and coul...

18 dagar ago | 1

Answered

Is it possible to find the limit as a function approaches a complex number?

If seem that what you want can be derived from the the Laurent series of G about p_i I have no idea if Matlab symbolc can compu...

Is it possible to find the limit as a function approaches a complex number?

If seem that what you want can be derived from the the Laurent series of G about p_i I have no idea if Matlab symbolc can compu...

19 dagar ago | 1

Answered

How do I calculate the correlation between the rows two large matrices?

Just use the formula of correlation % Fake data for testing A = rand(10,5); B = rand(10,5); Ac = A - mean(A,2); Bc = B - ...

How do I calculate the correlation between the rows two large matrices?

Just use the formula of correlation % Fake data for testing A = rand(10,5); B = rand(10,5); Ac = A - mean(A,2); Bc = B - ...

19 dagar ago | 0

| accepted

Answered

How to generate uniformly distributed points inside the volume of frustrum with base radius R and tip radius r and with a height of h.

Here we go r = 1; R = 2; % must be > r h = 3; if R <= r error('Non valid parameter') end Zmin = r*h/(R-r); % Posi...

How to generate uniformly distributed points inside the volume of frustrum with base radius R and tip radius r and with a height of h.

Here we go r = 1; R = 2; % must be > r h = 3; if R <= r error('Non valid parameter') end Zmin = r*h/(R-r); % Posi...

20 dagar ago | 0

| accepted

Answered

solving nonlinear equation including max function

The dumb method (buts surely reliable and give all possible solution) is to assume one of the 4 combinations rhs max in (1) is ...

solving nonlinear equation including max function

The dumb method (buts surely reliable and give all possible solution) is to assume one of the 4 combinations rhs max in (1) is ...

21 dagar ago | 0

Answered

While loop not breaking even though condition is met.

Just guessing; Might be it breaks but your function is entered again or there are many instances of function in queue, log more ...

While loop not breaking even though condition is met.

Just guessing; Might be it breaks but your function is entered again or there are many instances of function in queue, log more ...

21 dagar ago | 1

| accepted

Answered

Applying boundary conditions on a cubic spline interpolation

You can use my function spline1d available here https://fr.mathworks.com/matlabcentral/fileexchange/24996-spline-derivative?s_ti...

Applying boundary conditions on a cubic spline interpolation

You can use my function spline1d available here https://fr.mathworks.com/matlabcentral/fileexchange/24996-spline-derivative?s_ti...

22 dagar ago | 0

Answered

Generate random numbers with truncated Pareto distribution

According the https://en.wikipedia.org/wiki/Pareto_distribution the pareto has bounded on the lower side by what they called xm...

Generate random numbers with truncated Pareto distribution

According the https://en.wikipedia.org/wiki/Pareto_distribution the pareto has bounded on the lower side by what they called xm...

22 dagar ago | 0

Answered

inpolygon usage with big matrices or faster function

Try this https://fr.mathworks.com/matlabcentral/fileexchange/27840-2d-polygon-interior-detection?s_tid=srchtitle At some point ...

inpolygon usage with big matrices or faster function

Try this https://fr.mathworks.com/matlabcentral/fileexchange/27840-2d-polygon-interior-detection?s_tid=srchtitle At some point ...

22 dagar ago | 0

| accepted

Answered

Comparing between and within columns of matrix

A=[2 3 4 5 10 7 15 9 16 12 17 18 19 20]; [As,is] = sort(A(:)); col = 1 + (is>size(A,1...

Comparing between and within columns of matrix

A=[2 3 4 5 10 7 15 9 16 12 17 18 19 20]; [As,is] = sort(A(:)); col = 1 + (is>size(A,1...

22 dagar ago | 0

Answered

fminunc : A VERY STRANGE PROBLEM!

Just shooting in the dark here and wonder if you let the UseParallel option of fminunc to true or false? It could be that the ...

fminunc : A VERY STRANGE PROBLEM!

Just shooting in the dark here and wonder if you let the UseParallel option of fminunc to true or false? It could be that the ...

24 dagar ago | 0

Answered

Can we Generate a Random Matrix with No Repeated Elements

Just the reshape long vector returned by randperm m = 3; n = 2; A = reshape(randperm(10,m*n), m, n)

Can we Generate a Random Matrix with No Repeated Elements

Just the reshape long vector returned by randperm m = 3; n = 2; A = reshape(randperm(10,m*n), m, n)

24 dagar ago | 0

| accepted

Answered

How to rank 3d matrix across 2 dimensions

iNames(VarSORT); won't change iNames, you need to assign the expression to a variable VarsRank iVars = zeros(361,181,5); iVa...

How to rank 3d matrix across 2 dimensions

iNames(VarSORT); won't change iNames, you need to assign the expression to a variable VarsRank iVars = zeros(361,181,5); iVa...

24 dagar ago | 0

Answered

Efficient construction of positive and negative matrix

If your B is given then the 2nd method in this script is faster P = [1 3 8 18]; N = 20; B = fliplr(dec2bin((1:2^N)-1,N)-'0'...

Efficient construction of positive and negative matrix

If your B is given then the 2nd method in this script is faster P = [1 3 8 18]; N = 20; B = fliplr(dec2bin((1:2^N)-1,N)-'0'...

25 dagar ago | 0

Answered

Optimoptions - Invalid solver specified error

Check if you have license and installed optimization toolbox by typing ver

Optimoptions - Invalid solver specified error

Check if you have license and installed optimization toolbox by typing ver

25 dagar ago | 0

| accepted

Answered

Matrix Product optimization with Bsxfun

You simply cannot invent something that does not exist (support) in MATLAB, the function mtimes is not supported by bsxfun see f...

Matrix Product optimization with Bsxfun

You simply cannot invent something that does not exist (support) in MATLAB, the function mtimes is not supported by bsxfun see f...

27 dagar ago | 1

| accepted

Answered

how to flip a function

f = @(x) x.^3; ivf = @(y) y.^(1/3); g = @(x)x; ivg = @(y) y; a = 0; b =1; fplot(f, [a, b]), hold on fplot(g, [a, b], 'Li...

how to flip a function

f = @(x) x.^3; ivf = @(y) y.^(1/3); g = @(x)x; ivg = @(y) y; a = 0; b =1; fplot(f, [a, b]), hold on fplot(g, [a, b], 'Li...

27 dagar ago | 1

| accepted

Answered

How to create a second command window in my GUI?

Just let the main GUI (with welcome message and push button) to launch another MATLAB session system('matlab -r ...') with -...

How to create a second command window in my GUI?

Just let the main GUI (with welcome message and push button) to launch another MATLAB session system('matlab -r ...') with -...

28 dagar ago | 0

Answered

Matlab Mex File with OpenMP compiling and showing active threads but not actually using them

A little bit late reply. I believe the main reason is there is a problem in your code, not in the compilation option. because ...

Matlab Mex File with OpenMP compiling and showing active threads but not actually using them

A little bit late reply. I believe the main reason is there is a problem in your code, not in the compilation option. because ...

28 dagar ago | 0

Answered

How can I approximate this large matrix?

What about T = M; niter = 5: for k=1:niter T = M*(speye(size(M)) + T); end This returns T = M + M^2 + .... + M^6

How can I approximate this large matrix?

What about T = M; niter = 5: for k=1:niter T = M*(speye(size(M)) + T); end This returns T = M + M^2 + .... + M^6

28 dagar ago | 1

Answered

Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN

Replace ^2 by .^2 (with the dot) in fe if you want to square element wise. There migjt be some other operation like * or / that...

Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN

Replace ^2 by .^2 (with the dot) in fe if you want to square element wise. There migjt be some other operation like * or / that...

28 dagar ago | 0

Answered

Contradictory results in command window with variable class and ischar function?

class structure(8).timetotemp is like class('structure(8).timetotemp') which return char. The correct function syntax call ...

Contradictory results in command window with variable class and ischar function?

class structure(8).timetotemp is like class('structure(8).timetotemp') which return char. The correct function syntax call ...

28 dagar ago | 1

| accepted

Answered

How to speed up MEX function?

Last experience, Time with C OpenMP, Intel Parallel Studio XE 2022 CIntel_elapsed_time = 0.0574 [sec] 2.5 faster than MATLAB ...

How to speed up MEX function?

Last experience, Time with C OpenMP, Intel Parallel Studio XE 2022 CIntel_elapsed_time = 0.0574 [sec] 2.5 faster than MATLAB ...

29 dagar ago | 1

| accepted