Réponse apportée
Find first item with a certain condition and use it, instead of finding all items with that condition
Process by block, eventually you get the result after a couple of minutes p = zeros(1,100); p(1) = 3; n = 10^10; m = 1e7; ...

plus de 5 ans il y a | 0

Réponse apportée
how to find kshortest path or use Dijkstra algorithm for 12 plot points.
Assuming you want to find all paths from 1 to 12, using the code AllPath here, here is the 6 paths with the total distances (euc...

plus de 5 ans il y a | 1

Réponse apportée
fminsearch with matrices help
Sort out the dimensions of the matrix before doing anything on paper, programming, etc... >> x=rand(150,3); >> A=rand(3,3) ...

plus de 5 ans il y a | 0

Réponse apportée
Combination of choices - recursive function
Recursive method maxsum=16 lo=1; up=Inf; start=5; [~,A] = price(start, lo, up, maxsum) %% function [p, A] = price(sta...

plus de 5 ans il y a | 0

Réponse apportée
Combination of choices - recursive function
This is non-recusive approach (recursive is perhaps more scalable) maxsum=16 lo=1; % 2 up=Inf; % 8 start=5; % estimate ...

plus de 5 ans il y a | 1

Réponse apportée
Solve as Optimization Problem in Matlab
c=[15 16 17]; t = 121; A = [ c -1; -c -1]; b = [ t; -t]; f = [zeros(length(c),1); 1]; LB = 0*f; x = intlinpr...

plus de 5 ans il y a | 3

Réponse apportée
Should I use the absolute value of fast Fourier transform or the conjugate in signal analysis?
Y.*conj(Y) is abs(Y)^2

plus de 5 ans il y a | 0

Réponse apportée
Create a binary matrix for more than 50 variables
fprintf('you need a PC with %1.0f Tb of RAM\n', (2^50*50*8)/1e12)

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Cut out all of a square array except for a specified NxN section in the middle.
This works on nd-array, any size (>=m) in all dimension: i = num2cell(floor((size(x)-m)/2)+(1:m)',2) FinalMatrix = x(i{:})

plus de 5 ans il y a | 1

Réponse apportée
What is missing from MATLAB #2 - the next decade edition
No big deal but I wish SIGN(X) function could return 1 for X=0 instead of 0. May be implementing an option to not break the comp...

plus de 5 ans il y a | 1

Réponse apportée
Generate random number from custom PDF and CDF
This is an exact generation, since the cdf is invertible by close formula: (EDIT1: simplify the code) a = 4; n = 1e6; q = 1...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
rearrangement rows of matrices
A = reshape(A,[5 3 5]); A = permute(A,[1 3 2]); A = reshape(A,[5 15]);

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
I don't know how to prove sin^2(x)+cos^2(x)=1
Definition exp(x) = sum x^k/factorial(k). Property (provable here) exp(x+y) = exp(x)*exp(y) Definitions sin(x) = 1/(2i) (e...

plus de 5 ans il y a | 0

Réponse apportée
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.554125e-20.
Try x = A\L you might reduce the cnd to 1e-10, still pretty high. (not N\n, which won't do anything better than inv(N) IMO)

plus de 5 ans il y a | 0

Réponse apportée
4 unknown 3 nonlinear equation solution with minimum norm
I change your last equation rhs to 600 (otherwise there is NO solution). Here is two methods to find the minimum norm solution....

plus de 5 ans il y a | 2

| A accepté

Réponse apportée
The best way to add MATLAB/Simulink plots/figures to a Latex document
I don't know is it's the best but I export to EPS set(fig,'renderer','Painters'); print(fig, 'figurexxx.eps','...

plus de 5 ans il y a | 0

Réponse apportée
How to set mutually exclusive arguments in matlab?
function out = twoStats(x,y) arguments x = []; y {MustBeExclusive(x,y)} = []; end % out = ... ...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Bug in patch rendering?
I wouldn't call it a bug, it is just a poorer precision of rendering, wharever causes it (possibly quantification of calculation...

plus de 5 ans il y a | 0

Réponse apportée
Hello everyone, I have a question in optimization
The constraint (1c) norm(R11∗*w+r00, Inf) >= rm can be transformed as a union of 42 halfplanes R11(i,:)*w+r00(i,:) >= rm or...

plus de 5 ans il y a | 2

| A accepté

Réponse apportée
Creating Diagonal Matrix from a Vector
>> g=[1 2 3] g = 1 2 3 >> p=length(g); >> s=10; >> A=full(spdiags(repmat(g,s,1),0:p-1,s,s+p-1)) A = ...

plus de 5 ans il y a | 0

Réponse apportée
Function to solve unknowns in Ka=b. Where K is a square matrix fully known, however, knowns and unknowns are scattered in a & b.
You might need to carry out some normalization of a, b so that they are unitless before doing this. % Generate test data m = ...

plus de 5 ans il y a | 0

Réponse apportée
Recursion to compute convolution
Here is a hint, you must replace XXX and YYY with something (after all it's your homework) function P = Psum(n, k, alpha) if k...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Can this for-loop be vectorized?
u = setdiff(locs2,locs); % if locs2 is sorted and does not intersect with locs % you can replace u by locs2 steps = interp1(u...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
How to use regularization with lsqnonlin function
You are free to incorporation anything in the objective function, e.g., l^2 regularization regcoef = some_small_coef; fun = @(...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
multiplying matrix by another matrix element and using it in a command
This must be the fastest if your T is a large vector [P,D] = eig(Q); e = exp(diag(D)*T(:).'); e = reshape(e,1,size(Q,1),lengt...

plus de 5 ans il y a | 0

Réponse apportée
Missing patch face color
Check if all your data do not contain NaN, Inf or such. all(isfinite(x(:))) && all(isfinite(yCI95(:))) && all(isfinite(yMean(:)...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
subfunction in Matlab or many functions in one edite file
Write them in 2 separate mfiles. Only one function per file (the top one) is visible outside.

plus de 5 ans il y a | 0

Réponse apportée
Hello every one, I have a question related to approximation of functions based on norms
l1 and linfinity can be formulate as linear programming, so LINPROG is better.

plus de 5 ans il y a | 1

Réponse apportée
Sparse matrix memory usage clarification
MATLAB allocates a larger memory than nnz for sparse matrix, it's call nzmax, with some strategy that is not documented. You sho...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Solving complex integro-differential equation
For omega with imag(omega) < 0, the solution of the integro-differential eqt (dc/dt)(t) = -c(t)/2 * integral_0^inf exp(i*omega*...

plus de 5 ans il y a | 0

| A accepté

Charger plus