Answered
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)

11 days ago | 0

Answered
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{:})

11 days ago | 1

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

11 days ago | 0

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

12 days ago | 1

| accepted

Answered
rearrangement rows of matrices
A = reshape(A,[5 3 5]); A = permute(A,[1 3 2]); A = reshape(A,[5 15]);

12 days ago | 0

| accepted

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

12 days ago | 0

Answered
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)

12 days ago | 0

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

12 days ago | 2

| accepted

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

12 days ago | 0

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

12 days ago | 0

| accepted

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

13 days ago | 0

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

13 days ago | 2

| accepted

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

13 days ago | 0

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

13 days ago | 0

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

13 days ago | 1

| accepted

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

14 days ago | 0

| accepted

Answered
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 = @(...

14 days ago | 1

| accepted

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

14 days ago | 0

Answered
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(:)...

14 days ago | 0

| accepted

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

14 days ago | 0

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

15 days ago | 1

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

15 days ago | 1

| accepted

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

15 days ago | 0

Answered
use patch to plot hexahedron with 20 nodes
Here we go [x,y,z]=ndgrid(0:2); xyz = [x(:) y(:) z(:)]; xyz(sum(xyz==1,2)>1,:)=[]; x=xyz(:,1);y=xyz(:,2);z=xyz(:,3); a=atan...

15 days ago | 2

| accepted

Answered
Simplification of two for loops
i = (1:N)'; j = 1:N; radius = sqrt((i-i1).^2+(j-j1).^2); M = (1-sin((pi*radius)/(2*radius1))).*exp(w*radius); M(radius>=radi...

17 days ago | 0

Answered
Sorting and indexing multidimensional arrays
[B,I] = sort(A,3,'descend'); I is ndarray same size as A and B, values is 1:size(A,3) such that for any i,j A(i,j,I(i,j,:)) ...

17 days ago | 1

Answered
How to use implicit model functions in Curve fitting toolbox
Why not just solving using the linear algebra, seem this straighforward method does the job xy = load('new.txt'); x = xy(:,1);...

17 days ago | 1

Answered
Is there any way to speed up the function `changem`?
Sorry; I don't speed changem up, I just remove it entirely. function TR1 = simpleTR(TR) F = TR.ConnectivityList; n = size(F,2...

17 days ago | 0

| accepted

Answered
Polynomial as product of two vectors
Try this a = [1 2 3 4 ]; syms x f = [x,x^3,x,x^3].'; a*f

17 days ago | 0

| accepted

Answered
Tall Tables and Logical Matrices
Please try this [tf,j] = ismember([zensus.FLW zensus.ZLW],[loorarea.FLW floorarea.ZLW],'rows'); i = find(tf); j = j(tf); zen...

18 days ago | 0

Load more