Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Could anyone help me with the following code

1 visualizzazione (ultimi 30 giorni)
Prabha Kumaresan
Prabha Kumaresan il 23 Lug 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
code:
user=[2 4 ];
R=[2 3]
Xmax=1
Ymax=1
for t = 1:length(user)
for i = 1:length(R)
radius = R(i)
xsd=ones(1,user(t))*Xmax
ysd=ones(1,user(t))*Ymax
rrx=radius*sqrt(rand(1,user(t)))
thetarx=2*pi*rand(1,user(t))
xrx=xsd+rrx.*cos(thetarx)
yrx=ysd+rrx.*sin(thetarx)
th = 0:pi/100:2*pi
xunit = radius * cos(th) + Xmax
yunit = radius * sin(th) + Ymax
figure
plot(xunit, yunit)
hold on
plot(ysd,xsd,'r^')
hold on
plot(yrx,xrx,'ko')
hold on
end
end
I want to have the graph for 2 user with respect to R=[2 3] on the same figure such that the 2 users should be scatterd.Similarly for 4 user with respect to R=[2 3] on the same figure such that the 4 users should be scatterd.Could anyone please help me on this.

Risposte (2)

Adam Danz
Adam Danz il 23 Lug 2018
Modificato: Adam Danz il 23 Lug 2018
The template below will create a figure for each t-user and on each figure will be plotted all Rs for each t_th user.
for t = 1:length(user)
figure
axis
hold on
for i = 1:length(R)
plot()
end
end
This second template will create only 1 figure and all data will be plotted on the same axis.
figure
axis
hold on
for t = 1:length(user)
for i = 1:length(R)
plot()
end
end
Did that answer your question?
  9 Commenti
Prabha Kumaresan
Prabha Kumaresan il 24 Lug 2018
i want two separate figures with respect to 2 user and 4 user. If it is with respect to 2 user the figure should contain only 2 users with respect to two different radius.But according to the code i am getting 2 users each for different radius which i doesnt need.so in total with respect to two radius i need to get 2 users which i actually need.Could you please help me on this.
Adam Danz
Adam Danz il 24 Lug 2018
Prabha, I don't understand what you need. Please describe each figure or draw a picture and upload it.
Tell me what's wrong here:
  1. you want two figures
  2. In figure 1, there will be data from 2 users (4 data points).
  3. In figure 2, there will be data from 4 users (8 data points).
  4. In figure 1, there should be two circles.
  5. In figure 2, there should also be two circles.
More importantly, is this your code or are you trying to adapt someone else's code? Have you tried stepping through the code in debug mode to understand what the problem is? Please reply to those questions first before I can help you more.

Prabha Kumaresan
Prabha Kumaresan il 23 Lug 2018
I want two separate figures one with respect to user=2 containing two different radius and other with respect to user =4 with two different radius.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by