need help with pointer movement on grid
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I have a grid,say 150*150m with each cell 0.5*0.5m making it a grid of 300*300 cells. I want to move pointer in a random arc path such that the pointer covers each cell (cell should be covered completely) in time steps( if that can be included as well) along its path. The pointer dimensions 1*1m (i.e. spanning 2*2cells in either direction). i need help with coding it.
1 件のコメント
Walter Roberson
2016 年 12 月 1 日
When moving from one location to another, what are the allowed changes in position? For example is it only permitted to move left, right, up, down, by one unit? Or is it permitted to move diagonally by one? Is it permitted to move more than one cell at a time? Is it permitted to move back to where it was immediately previously? Is it permitted to move back to somewhere it has been before? Is each location to be visited exactly once, so the 300*300 grid would be completely covered in exactly 90000 steps?
採用された回答
KSSV
2016 年 12 月 1 日
clc; clear all ;
% N = 300 ; M = 150 ;
N = 100 ; M = 50 ;
[X1,Y1] = MeshRectanglularPlate(150,150,N,N) ;
[X2,Y2] = MeshRectanglularPlate(150,150,M,M) ;
nel = size(X2,2) ;
Ele = 1:nel ;
for i = 1:nel
% pick one element randomly
ele = randsample(Ele,1) ;
patch(X1,Y1,'w') ;
hold on
patch(X2(:,ele),Y2(:,ele),'r')
hold off
% remove the elemnet picked
Ele = setdiff(Ele,ele) ;
pause(0.5)
end
download the function MeshRectanglularPlate from the link: http://in.mathworks.com/matlabcentral/fileexchange/33731-meshing-a-plate-using-four-noded-elements/content/Plate%20Mesh/MeshRectanglularPlate.m
17 件のコメント
h b
2016 年 12 月 1 日
showing 'Error using patch. vectors must be the same length'
KSSV
2016 年 12 月 1 日
which line? It worked fine for me.....did you use the function?
h b
2016 年 12 月 1 日
編集済み: Walter Roberson
2016 年 12 月 1 日
two diff grids are displayed but no pointer is being shown
Are you taking a fine grid? Try to use a coarse one....like I have used 100 and 50. I get something like the image shown for one step.

h b
2016 年 12 月 1 日
error being showed in line- patch(X1,Y1,'w');
KSSV
2016 年 12 月 1 日
what error? what version you are using?
h b
2016 年 12 月 1 日
MATLAB Version: 9.1.0.441655 (R2016b)
KSSV
2016 年 12 月 1 日
YOu have not specified what error it is..you may also try fill instead patch
h b
2016 年 12 月 1 日
same is being displayed with fill. 'Error using fill Vectors must be the same length' i will check again..
KSSV
2016 年 12 月 1 日
What is size of X1 and Y1? Earlier you said two grids are shown and no pointer.
h b
2016 年 12 月 1 日
編集済み: Walter Roberson
2016 年 12 月 1 日
Following sizes
X1 = 10201x2 double ; Y1 = 10000x4 double X2 = 2601x2 double ; Y2 = 2500x4 double
input as per your code.
output
i am getting two figures with grid shown without any pointer as well as the error message in the line patch(X1,Y1,'w') ;
KSSV
2016 年 12 月 1 日
There is a error....sizes of X1 and Y1 should be same...same is case with X2 and Y2. Hey, I apoologize, I made changes to the function....you use this function. ;).
h b
2016 年 12 月 1 日
it worked. Thank you so much sir.
h b
2016 年 12 月 1 日
Here, is it possible for the pointer to move in a path(straight/arc) cell-by-cell?
KSSV
2016 年 12 月 1 日
In the present code, pointer moves randomly..if you want in a path, you have to specify the path first and then follow the path.
h b
2016 年 12 月 6 日
1. i am unable to move pointer(having dimension 2cells*1cell) cell by cell in a straight path.
2. is it posible to keep certain column of cells in the grid as rotated matching the path shape. eg. in an arc path, square cells rotated to match the shape. Thanks in advance
h b
2017 年 1 月 13 日
i have an issue to formulate logic. how to move pointer in any straight line(column or row) cell by cell. please help
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
