i need the nodes to move in different direction

Technical Source
1 min readMar 22, 2023

--

clear all;

X=200;
Y=200;
Num=10;
n=10;
Loc_Nodes=zeros(2,Num);
 for i=1:2    x0=rand(1,Num)*X;
y0=rand(1,Num)*Y;
Loc_Nodes(1,:)=x0;
Loc_Nodes(2,:)=y0;
end
r= randsample(n,1);
while(r<11)
for j=1:10
%k=[0,20,30,45,60,90,120,135,150,160,180,200,210,225,240,270,290,300,315,330,360];
r= randsample(n,1);
theta=360*rand;
[x,y]=pol2cart(deg2rad(theta),r);
x0=x0+x;
y0=y0+y;
Loc_Nodes(1,:)=x0;
Loc_Nodes(2,:)=y0;
scatter( Loc_Nodes(1,:), Loc_Nodes(2,:),'filled');
xlim ([0 210])
ylim ([0 210])
xticks(0:10:200)
yticks(0:10:200)
drawnow;
pause(1)
end
end

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

I have no idea what your question is.

If you want the rand function to return negative numbers, subtract it from 0.5.

Example —

x0 = (0.5-rand(1,Num))*X;
y0 = (0.5-rand(1,Num))*Y;

About half of the values of ‘x0’ and ‘y0’ will be negative.

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet