how can i plot the graph for the following code
显示 更早的评论
nb_user = 5;
sub_used = 3;
nb_sub = sub_used * nb_user;
association = zeros(nb_user,nb_sub);
throughput_thre = 0;
sub_order = [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5];
for s = 1:nb_user
association(s,((s-1)*sub_used+1):(s*sub_used)) = ones(1, sub_used);
end
for s = 1:nb_user
for k = 1:nb_sub
if association (s,k) == 1
throughput(s,k) = 3*sub_order(k);
end
end
end
u =0;
for s = 1:nb_user
for k = 1:nb_sub
u = u + throughput(s,k);
end
end
association;
throughput;
回答(1 个)
KSSV
2017-11-9
nb_user = 5;
sub_used = 3;
nb_sub = sub_used * nb_user;
association = zeros(nb_user,nb_sub);
throughput= zeros(nb_user,nb_sub);
throughput_thre = 0;
sub_order = [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5];
for s = 1:nb_user
association(s,((s-1)*sub_used+1):(s*sub_used)) = ones(1, sub_used);
end
for s = 1:nb_user
for k = 1:nb_sub
if association (s,k) == 1
throughput(s,k) = 3*sub_order(k);
end
end
end
u =0;
for s = 1:nb_user
for k = 1:nb_sub
u = u + throughput(s,k);
end
end
x = 1:nb_user ;
y = 1:nb_sub ;
[X,Y] = meshgrid(x,y) ;
figure
surf(X,Y,association') ;
figure
surf(X,Y,throughput') ;
5 个评论
Prabha Kumaresan
2017-11-10
KSSV
2017-11-11
@Prabha....it is you who gave the code.....and asked to plot..that's the way to plot.....it is you, who have to explain......:)
Prabha Kumaresan
2017-11-11
KSSV
2017-11-11
That's what it does..it plots a surface....as you have two dependent parameters.
Prabha Kumaresan
2017-11-11
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!