How to change the shape of node

I am learning wireless sensor network basic. I want to change the shape of nodes . Here nodes are in circle shape but I want nodes is in car shape. Please help me. How I can do that?

3 Comments

How do you create the image currently? How are the coordinates defined?
This is the code . I want to change the shape of node. How I can do this ?
clc;
clear all;
%imp=menu('Generate Network','DOS Detection');
no_nodes=input('Enter the no of nodes');
net_length=input('Enter the Length of the network');
net_width=input('Enter the width of the network');
for i=1:no_nodes
x_loc(i)=net_length*rand;
y_loc(i)=net_width*rand;
node_id(i)=i;
plot(x_loc(i),y_loc(i),'b^','linewidth', 2);
text(x_loc(i)+10,y_loc(i)+10,['N',num2str(i)]);
hold on;
xlabel('Network Length');
ylabel('Network Width');
grid on;
pause(0.5);
end
source=round(no_nodes*rand);
if source==0
source=5;
end
destination=round(no_nodes*rand);
if destination==0
destination = 6;
end
figure(1);
Jan
Jan on 16 May 2021
Edited: Jan on 17 May 2021
Thanks. Now it is clear, how the coordinates are defined. The next step is to explain, what exactly a "car shape" is.

Sign in to comment.

Answers (1)

Here is a kind of helpful code you can start working with to substitute the plot markers with images w.r.t your definitions:
https://www.mathworks.com/matlabcentral/answers/481183-insert-image-as-a-marker-in-plot

3 Comments

This is the car shape. I want to plot this shape instead of *.
I am trying to execute this code but it does not work for me.
x = 1:10;
y = 5*rand(size(x)) + 2.5;
[marker,m] = imread('images.png');
marker = imresize(marker,0.5);
markersize = [1,1]; %//The size of marker is expressed in axis units, NOT in pixels
x_low = x - markersize(1)/2; %//Left edge of marker
x_high = x + markersize(1)/2;%//Right edge of marker
y_low = y - markersize(2)/2; %//Bottom edge of marker
y_high = y + markersize(2)/2;%//Top edge of marker
for k = 1:length(x)
imagesc([x_low(k) x_high(k)], [y_low(k) y_high(k)],marker)
hold on
end
axis equal
hold off
Please explain, what "does not work" means. Sharing this important information is a good idea, if you want to get the problem solved.
Means i want to place node in car shape instead of *. This code show only 1 image in the whole graph . I want to place multiple car shape node in graph.

Sign in to comment.

Categories

Find more on Networks in Help Center and File Exchange

Tags

Asked:

on 16 May 2021

Edited:

Jan
on 17 May 2021

Community Treasure Hunt

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

Start Hunting!