How can I plot different quadrilateral with different range of coordinates per node?

5 ビュー (過去 30 日間)
I have a square with dimension of 50x50 with four nodes, each node will vary in range of (-10,10) which means each corner of the square has 3 nodes along x axis (Fig below)
I want to connect each node per corner to nodes in other corners in order to make different quadrilateral with different shape. For this special case It would be 3^4=81 different shapes and I need to plot them as subplot (8,8,n), I have written intial part of the code but I dont know how to connect all coressponding nodes to each other to make 64 different quadrilateral. Could you please tell me how to do this? Thanks
clc;
clear;
close all;
x = [-25; 25; 25; -25];
y = [-25; -25; 25; 25];
for i=1:4
for j=-10:10:10
x(i,:)=x(i,:)+j;
Y(:,:)=y;
subplot(2,2,i);
plot(x,y,'.');
xlim([-50 50])
ylim([-50 50])
k = boundary(x,y);
hold on;
plot(x(k),y(k));
end
end

採用された回答

darova
darova 2019 年 7 月 18 日
Look at my soultion
clc,clear
x = [-1 1 1 -1]*25;
y = [-1 -1 1 1]*25;
plot(x,y,'or'); % plot original nodes
axis([-1 1 -1 1]*40) % axes boundaries
hold on
k = 0;
for i = 1:4
for j = -10:10:10
x1 = x; % create a copy of "x"
x1(i) = x1(i) + j; % modify current node
% k = k + 1;
% subplot(4,3,k)
h = plot([x1 x1(1)],[y y(1)],'.-b');
pause(1)
delete(h);
end
end
hold off
Do you like it?
  4 件のコメント
darova
darova 2019 年 7 月 19 日
You can use for loop to create c vector
c(1).x=M(1,1);
c(1).y=M(1,2);
Hamed Bolandi
Hamed Bolandi 2019 年 7 月 19 日
Thanks for your answer.

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

その他の回答 (1 件)

Hamed Bolandi
Hamed Bolandi 2019 年 7 月 18 日
編集済み: Hamed Bolandi 2019 年 7 月 18 日
Thanks for your reply. This script is a part of bigger script. The main script should creates n^m different quadrilateral from 12 nodes. ( where, n is number of nodes per corner of quadrilateral and m is the number of corners of quadrilateral which in this case is 3^4=81) You can see the coordinate of tthe nodes in the first part as x and y. I labeled each node from 1 to 12 like figure in the first qustion. For instance: nodes with labels 1-4-7-10 create a first quadrilateral and the 1-4-7-11, 1-4-7-12 1-5-7-10,1-5-7-11 and 1-5-712 are respectively for the 2nd to 6th quadrilarerals and so on... to make 81 quadrilateral with different gemoetry.
you can see all the labels and the coordinates of the nodes in the attached excel file.
Also, I attached my main code.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by