Matlab Beg {1}-inverse

Source: Internet
Author: User

Recently a wave of scientific research like a mad dog.

The last time or the partial differential equation of the undergraduate exam, a semester did not do homework and then go to the hospital to slow test failure, evening with the students walk through the red carpet after the preview, the next day eight points exam. And then it was C-.

So, never underestimate the determination of a lazy man.

--------------------------------------------------------------------------------------------------------------- ---------------------------------

Why write this today, because I suspect that matlab inside the PINV used to beg {1}-inverse, there will be a lot of precision error, so I intend to find a request {1}-inverse function.

Matlab There is no ready-made, and then online can not find, in order to lazy not to write my own can only use Rref.

The core idea is to use the rref inside the Gaussian elimination to do two times, because no rref how to record the transformation matrix, so the method of additional matrix can be recorded under the transformation matrix (must thank my two high-generation teachers haha).

I'm pretty hard to get lazy.

Put a code below, reach the party, wrong not to find me. (I want to reach out too!!!) )

function [y] = GINV (a)    [m,n] = size (a);    M1 = Cat (2,a,eye (m));    M2 = Rref (M1);    PA = M2 (:, 1:n);    P = M2 (:, n+1:n+m);    M3 = Cat (2,PA ', Eye (n));    M4 = Rref (M3);    J = M4 (:, 1:m);    Q = M4 (:, m+1:m+n);    y = Q ' *j ' *p;end

Stole the lazy mood good, write a blog to commemorate the haha.

(PostScript: Accuracy has improved.) However, and eggs, I found that the PINV error in the matrix is relatively small when the results do not make very outrageous, that is, or wrong, checked the discovery is not the wrong son code, hey. )

Matlab Beg {1}-inverse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.