Rank: 561 based on 196 downloads (last 30 days) and 4 files submitted
photo

Calvin Price

E-mail

Personal Profile:

Professional Interests:

 

Watch this Author's files

 

Files Posted by Calvin View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Nov 2009 Full Rank Factorization Performs a full rank factorization, X=KL Author: Calvin Price linear algebra, full rank factorizati..., mathematics, full rank decompositi... 40 1
  • 1.0
1.0 | 1 rating
26 Dec 2008 Screenshot Plot a plane or line in 3D User specifies two independent vectors, and the corresponding plane is graphed. Author: Calvin Price plane, plot, subspace, 3d 90 0
28 Jul 2008 Create orthonormal vectors Creates a random set of orthonormal vectors Author: Calvin Price orthonormal vectors, linear algebra, orthogonal vectors, independent vectors 22 0
25 Feb 2008 Sort Eigenvectors & Eigenvalues Sort a set of eigenvectors and corresponding eigenvalues Author: Calvin Price eigenvalues, linear algebra, eigenvectors, sort, mathematics 44 2
  • 2.5
2.5 | 2 ratings
Comments and Ratings on Calvin's Files View all
Updated File Comment by Comments Rating
08 Apr 2008 Full Rank Factorization Performs a full rank factorization, X=KL Author: Calvin Price Davis, Tim

This function simply calls the MATLAB rref.m function, and then "determines" the rank of the matrix by looking at the number of zeros on the diagonal of the reduced matrix; the corresponding rows are then removed. This method has several problems. First, rref.m is not one of the computational workhorses of MATLAB. It is quite slow for large matrices. The SVD is more accurate, and faster in this case becase the SVD is built-in but RREF is an M-file (and a slow one at that). RREF is in MATLAB not for production use, but more for educational purposes. Second, looking for exact zeros is not appropriate. You should at least ensure the matrix is well-scaled, and then look for small values, not zeros. Your method is prone to errors due to trivial round-off errors.

I timed the SVD and FRD on the matrix rand(1000), which is full rank. The SVD took 19 seconds, whereas FRD took 79 seconds. The former is vastly more accurate and robust than this code, and 4 times faster.

25 Feb 2008 Sort Eigenvectors & Eigenvalues Sort a set of eigenvectors and corresponding eigenvalues Author: Calvin Price Hanselman, Duane

Please revise the help text to match standard MATLAB help text formating. This function would be useful if it gave the user more control over sorting, e.g., ascending or descending, or like that provided in esort (Control Toolbox) or cplzpair (basic MATLAB). For example, [p,idx]=esort(diag(D)); D=diag(p); P=P(:,idx); is much more useful.

25 Feb 2008 Sort Eigenvectors & Eigenvalues Sort a set of eigenvectors and corresponding eigenvalues Author: Calvin Price D'Errico, John

This is not bad code. Its merely not terribly good. It even does what it says it does, despite the triviality of that action.

What could the author have done better?

The help is barely acceptable. Excellent help would clearly specify the expected shapes and sizes of the inputs. It would explain what the variables are, not make us guess that D is the diagonal array of eigenvalues, P the array of eigenvectors. Instead, this code merely refers to the output of eig. The funny thing is, if we look at the help for eig, it calls the variables V and D. Yeah, I know that many texts use P and D for the eigenvectors and diagonal matrix of eigenvalues, but I'm sorry, this is not what I choose to call good.

Next, you are expected to infer how to use this code from a single poor example. The author apparently thinks we will know that D is an array of eigenvalues, since it is diagonal. I suppose that might make some sense. But a diagonal matrix can as easily be a set of linear independent vectors. If the example is to be a clear one, I'd have expected P to be a set of independent vectors. NOT true here.

If you write code for others to use, make it good. Make it useful. If its trivial code, at least document it well.

Next, good code would have error checks. What happens if the user screws up and passes in a VECTOR of eigenvalues instead of an array? This seems like an easy mistake one might make. Check the sizes of your arguments. Verify that they make sense. Don't just let Matlab respond with some random, unintelligent error. Help your user.

Also, good code will have an H1 line. An H1 line is the FIRST line of the help block. It is used by lookfor to search on for keywords, so that the user can find some piece of code they dug up last year with a name they cannot recall. What was the first line of help in this submission?

% this function takes in two matrices P and D, presumably the output

A better H1 line might have looked like

% Sort eigenvalues and corresponding eigenvectors

Part of me wanted to rate this as a 2 ("needs improvement"). Why did I choose a 3 rating? While the code really is trivial, it does have some help and an example. It even has a readable (and useful) line of internal comment for each line of code in the submission.

Top Tags Applied by Calvin
linear algebra, mathematics, 3d, eigenvalues, eigenvectors
Files Tagged by Calvin View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Nov 2009 Full Rank Factorization Performs a full rank factorization, X=KL Author: Calvin Price linear algebra, full rank factorizati..., mathematics, full rank decompositi... 40 1
  • 1.0
1.0 | 1 rating
26 Dec 2008 Screenshot Plot a plane or line in 3D User specifies two independent vectors, and the corresponding plane is graphed. Author: Calvin Price plane, plot, subspace, 3d 90 0
28 Jul 2008 Create orthonormal vectors Creates a random set of orthonormal vectors Author: Calvin Price orthonormal vectors, linear algebra, orthogonal vectors, independent vectors 22 0
25 Feb 2008 Sort Eigenvectors & Eigenvalues Sort a set of eigenvectors and corresponding eigenvalues Author: Calvin Price eigenvalues, linear algebra, eigenvectors, sort, mathematics 44 2
  • 2.5
2.5 | 2 ratings
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com