Find the transformation matrix

59 visualizzazioni (ultimi 30 giorni)
reincornator
reincornator il 1 Lug 2021
Commentato: John D'Errico il 1 Lug 2021
How to find the transformation matrix in MATLAB?
For example:
x1=[1;2];
x2=[4;5];
y1=[3;4];
y2=[2;1];
y1=S*x1;
y2=S*x2;
where S=[s1 s2; s3 s4]
Which function will help you find S?
upd №1: I know how to do it on a piece of paper. But maybe there is a standard function in MATLAB.

Risposta accettata

John D'Errico
John D'Errico il 1 Lug 2021
First, learn to use matrices, NOT numbered variables. Assuming that you have a matrix X, and a matrix Y, with x1 x2, y1, y2 as columns...
x1=[1;2];
x2=[4;5];
y1=[3;4];
y2=[2;1];
X = [x1,x2];
Y = [y1,y2];
then ONLY if the matrix X is non-singular does a solution exist. So is X singular? It must be of full rank if it is non-singular, or a small condition number.
rank(X)
ans = 2
cond(X)
ans = 15.2678
So X is non-singular. In that case,
format long g
S = Y/X
S = 2×2
-3.66666666666667 3.33333333333333 -6 5
Does S work? Of course. I could also have written it as S = Y*inv(X), but Y/X is a better choice in MATLAB.
norm(Y - S*X)
ans =
1.83102671940889e-15
So effectively zero, only floating point trash remains.
  4 Commenti
reincornator
reincornator il 1 Lug 2021
I was wrong. Thanks.
John D'Errico
John D'Errico il 1 Lug 2021
I showed how to use what IS the standard function in MATLAB.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Linear Algebra in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by