Extracting data from a matrix in slanted rectangular form

2 vues (au cours des 30 derniers jours)
Abhilash K S
Abhilash K S le 8 Fév 2017
Commenté : Saurabh Agarwal le 6 Juil 2021
i have data consisting of x, y and z . I want to extract data from the above matrix in a slanted rectangular shape( If I joined the vertex values of rectangles it will be slanted and there are 4 x values and 4 y values ). The image shows the contour of the data I want to extract the data in the rectangle as shown in the figure (Thick bordered).
thank you

Réponse acceptée

KSSV
KSSV le 8 Fév 2017
clear all
[X,Y,Z] = peaks(100) ; % data
% the slant rectangle I picked
rect = [
-1.5000 0.1399
-0.2005 1.6968
1.0300 -0.1224
-0.6014 -1.2770
-1.5000 0.1399
] ;
figure ; surf(X,Y,Z) ; view(2) ; hold on ; plot(rect(:,1),rect(:,2),'b') ;
% get the indices of piints which are inside the rectangle
id = inpolygon(X(:),Y(:),rect(:,1),rect(:,2));
% initilaize the required matrices
Xi = NaN(size(X)) ;
Yi = Xi ;
Zi = Xi ;
% fill the values inside rectangle
Xi(id) = X(id) ;
Yi(id) = Y(id) ;
Zi(id) = Z(id) ;
figure ;surf(Xi,Yi,Zi)
  4 commentaires
Abhilash K S
Abhilash K S le 8 Fév 2017
Thanks
Saurabh Agarwal
Saurabh Agarwal le 6 Juil 2021
From this inclined matrix (as rectangle is inclined) is getting. How to make a straight matrix from this?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by