Divide an area into equal sized small grids
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
joy
am 8 Mär. 2015
Kommentiert: Swati Sarangi
am 29 Okt. 2020
Hi,
I am working in WSN. I have created a sensor network of size (100 * 100)..How could i divide that region into equal sized small grids..Can meshgrid be used here? how?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 8 Mär. 2015
I’m not certain what you mean by ‘equal size small grids’, but if you want a (100x100) grid, this is one way to do it:
x = linspace(1, 100);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y,'k')
hold on
plot(Y,X,'k')
hold off
5 Kommentare
Star Strider
am 8 Mär. 2015
This code should work:
NrGrid = 6; % Number Of Grids
x = linspace(0, 100, NrGrid+1);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y,'k')
hold on
plot(Y,X,'k')
hold off
set(gca, 'Box','off', 'XTick',[], 'YTick',[])
axis square
The ‘NrGrid’ assignment is the number of grids created on each axis.
The new plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182226/image.png)
Swati Sarangi
am 29 Okt. 2020
@Star Strider
How can it be done in case of a 3D figure? like for a cuboid?
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!