Rotate matrix with interp2

3 ビュー (過去 30 日間)
Sung YunSing
Sung YunSing 2019 年 11 月 11 日
コメント済み: Sung YunSing 2019 年 11 月 14 日
I am trying to rotate a matrix to a specific direction(vector) by using interp2.
I input Matrix and a vector.
Matrix will be the object I want to rotate(2-D matrix of nxm).
The direction which i want to rotate to will be shown as a (unit) vector.
The vector will need to be a 2x2 matrix.
The first column will be the vector of direction and the second column will be the orthogonal vector of the first.
The logic of what I want to do is like doing a rotation matrix on Cartesian coordinate system, but the sin and cos will be replaced as a unit vector.
But what I get is just a matrix full of NaN.
function [Mq]=Rotation(Matrix,vector)
ly=length(Matrix(:,1));
lx=length(Matrix(1,:));
x=1:lx;
y=1:ly;
[X,Y]=meshgrid(x,y);
Xq=X*vector(1,1)-Y*vector(2,1);
Yq=X*vector(1,2)+Y*vector(2,2);
Mq=interp2(X,Y,Matrix,Xq,Yq);
end
  2 件のコメント
darova
darova 2019 年 11 月 11 日
Maybe you didn't define ph?
darova
darova 2019 年 11 月 12 日
I think you trying to extrapolate values
123.png

サインインしてコメントする。

採用された回答

Matt J
Matt J 2019 年 11 月 12 日
This might be what you want.
[X,Y]=meshgrid(x-mean(x),y-mean(y));
  1 件のコメント
Sung YunSing
Sung YunSing 2019 年 11 月 14 日
thanks a lot ~!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by