Answered
colorbar: cdata and colors
The CAXIS command can used to set the scaling limits on the color, in the same way that you set XLIM or YLIM. For example: ...

13 years ago | 1

| accepted

Answered
Block Diagonal matrix multiplication with a sparse matrix
Although (A'*B) can be done quickly, the answer is no longer sparse. It is just some complex matrix. So then you are basically m...

13 years ago | 0

Answered
about nested for loop
D=sum(sum(B.*(C*A*C')))

13 years ago | 2

Answered
Sorry but cannot fsolve this and don't know why
Ok, you have a very subtle, but pathological problem with your code. Compare this: y = [ (1)... +2] To this: ...

13 years ago | 0

Answered
Plot contours at a level I wish
Here's one idea. First change this line: contour(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]); to this (in order to get the ha...

13 years ago | 0

Answered
Matrix multiplication (best computational approach)
I think you might be better off grouping your multiplications so that you maximize matrix-vector products instead of matrix-matr...

13 years ago | 2

| accepted

Answered
Multiplying certain dimensions of two 3D matrices
A = rand(30,30,50); B = rand(30,30,80); C = reshape(A,900,[])'*reshape(B,900,[]);

13 years ago | 2

Answered
Triangular surface
There is also the SURF2PATCH function, which can turn quadrilaterals into triangles. For example: figure; [x,y,z] = sphe...

14 years ago | 0

Answered
Solving Systems of Linear Equations
Solving for each row of X is an independent optimization problem that can be solved easily with LSQNONNEG (available from the Op...

14 years ago | 0

| accepted

Answered
removing unwanted pixels
Maybe IMFILL might work? A = [1 1 1 1; 1 0 1 0; 1 1 1 0] imfill(A) imfill(A) - A

14 years ago | 0

Answered
Do what Excel does in curve fitting in Matlab
Wayne gives a good way to do it, but in the latest version of the Statistics Toolbox, there is some great functionality that mak...

14 years ago | 1

Answered
Matrix operations without for structure
M = 60e3; N = 2; A = rand(M,N); s = rand(N,N); Am = bsxfun(@minus,A,mean(A)); %subtract the column means ...

14 years ago | 0

Answered
How to solve b≤Cx≤z with linear programming?
You can solve this with LINPROG, but I think you need help in understanding how to formulate your constraints properly. Const...

14 years ago | 1

Answered
Sparse matrix memory problem
Sparse matrices keep track of data by each column. This means that if you have a lot of columns (here you have one billion of th...

14 years ago | 0

| accepted

Answered
Set boundary for least-square calculation
LSQLIN can do this: W = rand(10,5); y = rand(10,1); someOtherGivenNumber = 1.3; opts = optimset(optimset('ls...

14 years ago | 0

| accepted

Answered
Vectorise an n dimensional raise to the power loop
You can call BSXFUN more than once: x = rand(1,1000); m = 30; n = 40; tic P1 = zeros(m,n,numel(x)); for ...

14 years ago | 0

| accepted

Answered
Virtual Mouse Project
MATLAB can move the mouse around: x = 500; y = 600; set(0,'PointerLocation',[x y]); But, I think you do need t...

14 years ago | 0

Answered
vectorizing nested loops
Vectorization would probably involve calling NDGRID and then doing a bunch of logical indexing. It would take a lot more memory....

14 years ago | 1

Answered
Calculation/ Visualisation of circular planes in a 3D space
Here are two possible ideas. Given a circle center and a normal vector: R = 0.25; %Radius xyz = randn(1,3); %Circle cent...

14 years ago | 2

| accepted

Answered
Help with numerical differentiation
If you have the Curve Fitting Toolbox, there are some functions in there that may be of use, like FIT and DIFFERENTIATE: x ...

14 years ago | 1

Answered
need help optimizing this code...
You can simplify the loop like this: for i=1:n v = w(i)*s(i)*sum( w(i+1:n) .* s(i+1:n) ); dTot = dTot + v; ...

14 years ago | 1

Answered
Solving Higher Order Matrix Polynomials
If k and q are not too large, one idea is to try to solve it as an optimization problem. "Which elements of X will yield the ...

14 years ago | 0

Answered
Graphing the Fourier Transform of a Square pulse: Problems with filled in sinc function, frequency axis, and amplitude.
Two things. 1. As you noticed, you are defining your f incorrectly. The resolution of f is equal to 1/T, where T is equal to ...

14 years ago | 0

| accepted

Solved


Omit columns averages from a matrix
Omit columns averages from a matrix. For example: A = 16 2 3 13 5 11 10 8 9 7 ...

14 years ago

Solved


Factorize THIS, buddy
List the prime factors for the input number, in decreasing order. List each factor only once, even if the factorization includes...

14 years ago

Solved


Too mean-spirited
Find the mean of each consecutive pair of numbers in the input row vector. For example, x=[1 2 3] ----> y = [1.5 2.5] x=[1...

14 years ago

Answered
Speed up recursive loop
Do you know about the command "FILTER" from the Signal Processing Toolbox? This operation can be done very quickly. nobs ...

14 years ago | 3

Answered
calculation of mean , standard deviation and average for each pixel in an image M*N?
If you have the Image Processing Toolbox, the functions IMFILTER (can be used to do mean filtering on a neighborhood), S...

14 years ago | 1

Answered
Changing the number of input arguments while calling a function in a loop
The cell array as mentioned above is a reasonable approach. Another possibility would be to modify your function so that the fun...

14 years ago | 0

Answered
optimization
This type of problem can be easily set up in FMINCON, by employing the nonlinear constraint input parameter. As a concrete ex...

14 years ago | 0

Load more