Answered
Plotting heaviside unit step functions
If you replace the line with the heavisides in it with the one from my previous answer dydt(2) = (A*t >= 0) + 4*(A*(t-1) >=...

13 years ago | 1

| accepted

Answered
Plotting heaviside unit step functions
heaviside is a function from the symbolic toolbox - I'd be surprised your code doesn't complain when you try to call it. Why ...

13 years ago | 0

Answered
Economical use of memory
Matlab's semantics are pass-by-value but it only actually copies the matrix if you modify it within your function, "lazy copy" o...

13 years ago | 0

Answered
Why do you come to "MATLAB Answers"?
When I get blocked with my research, here at least I can make an epsilon contribution to something ...

13 years ago | 1

Answered
Why not use square brackets?
OK, I looked into this a little more rigorously. I thought I'd test James Tursa's suggestion from my previous answer to see if t...

13 years ago | 3

Answered
Why not use square brackets?
A quick test reveals that there is a small cost to including them tic for i = 1:1000000 A = [1:100]; end t1...

13 years ago | 1

Answered
??? Subscript indices must either be real positive integers or logicals. Using findpeaks
You've probably declared a variable called findpeaks by accident. Try which findpeaks and confirm it's actually pointin...

13 years ago | 1

Answered
MATLAB in unexpected places
On an episode of Harry's law (I can't remember which one), Tommy Jefferson (a fast-talking lawyer) boasts about a number of laws...

13 years ago | 0

Answered
matlab function
Why not just [M, N] = find(I, 1, 'first') ?

13 years ago | 0

Answered
Surface area from a z-matrix
If your data is smooth enough (assuming that's what you're after), then there is a really quick way to work out approximately th...

14 years ago | 1

Answered
Need help with newton's theorem (matlab)
It works fine - you're just using a (contrived!) nasty example. Plot your function between -3 and 20 and see where the first New...

14 years ago | 1

| accepted

Answered
Lagrange Multipliers
This is not a Matlab question, it's a calculus homework problem. Define a function f(x,y) that you want to minimise, a constrain...

14 years ago | 0

Answered
data fitting starting from a coupled system of differential equations
Hi Simona. I'm adding this as a new answer so that I can use code markup. You need a function that takes in K1, K2, K3 as inputs...

14 years ago | 0

Answered
plotting unit step function
Or as an anonymous function: f = @(t) (t > 1) - (t > 2) + (t < 2) - (t < 3) + (t > 3) - (t > 4); t = linspace(-5, 5, 200...

14 years ago | 0

Answered
How to create a solid spherical cluster with random distribution of points
Here's the lazy (no thinking, no maths) way. It will be slow(ish), but serves to illustrate the idea. I'm sure you can think up ...

14 years ago | 1

Answered
Handles: How do They Work?
The easiest way to do this is to define a constructor function that passes out a handle to be used in the ode solver by using ne...

14 years ago | 0

| accepted

Answered
Max / Min of sparse matrices
*EDIT* There was a mistake in the markers line and the s= line, fixed now. OK, here's an accelerated version. What made my pr...

14 years ago | 1

| accepted

Answered
Max / Min of sparse matrices
Can't do this one quite so cutely :) Try this (for rows), you can do the same thing for columns with a trivial modification ...

14 years ago | 0

Answered
Can I use quadprog when equality constraint matrix is not full rank?
If your equality constraint matrix is not full rank, then either your equality constraints are consistent, and dependent, or the...

14 years ago | 0

| accepted

Answered
Max/Min of nonzero rows/cols
B = A; B(B == 0) = NaN; colMax = max(B); colMin = min(B); rowMax = max(B, [], 2); rowMin = min(B, [], 2); ...

14 years ago | 2

| accepted

Answered
cell comparison with other cells in different rows
For the record, it would be better to use arrays rather than cell arrays for the coordinates (in fact for the whole thing, but t...

14 years ago | 0

| accepted

Answered
Non negligeable imaginary number after ifft even when hermitian symmetry is kept.
When you do your flipdim, shouldn't you be taking the complex conjugate also?

14 years ago | 1

Answered
Find element in matrix
Here's a slightly uglier way that will work. If you need the code to perform quickly, you'd obviously preallocate your arrays m ...

14 years ago | 1

| accepted

Answered
sum of series
I think you may need to try and ask your question more clearly. What you've written there reduces to 1 + 2 + 3 + ... If it's ...

14 years ago | 0

Answered
maximum position of element in a matrix
Pretty straightforward - the only complicating factor is that max only works down one dimension at a time, so you either have to...

14 years ago | 0

| accepted

Answered
handles to subfunctions?
From <http://www.mathworks.com/help/techdoc/matlab_env/f9-6232.html> The report does not list: ... Files called from ...

14 years ago | 2

Answered
How to control number of threads in FFT ?
I just tried it out on my Windows install (R2011b). No matter what you set maxNumCompThreads to, fftn only ever uses one thread....

14 years ago | 0

Answered
robot
<http://petercorke.com/Robotics_Toolbox.html>

14 years ago | 1

Answered
Get Feature from an image and match it from another image
There are lots of algorithms that do this. Try google for * SIFT * SUSAN * NCC * Harris etc. etc. There are many Matla...

14 years ago | 0

Answered
Affine transformation that takes a given, known ellipse and maps it to a circle with diameter equal to the major axis.
I'm writing this down as a new answer so I can get markup for the code snippets. Let's work with the first blob from regionprops...

14 years ago | 3

| accepted

Load more