Getting Different plot values

3 ビュー (過去 30 日間)
Brave A
Brave A 2022 年 8 月 5 日
コメント済み: Walter Roberson 2022 年 8 月 6 日
Hi,
I have this kind of data which is the position of each users (attached) but the problem when I plot them it's getting miss. Any suggestions to plot this data?
clear;
clf('reset');
max_iterations = 500;
xs = 1: max_iterations;
num_devices=50;
N=importdata('40_3_1.txt');
r=mean(reshape(N,2,[]));
r = r';
ys_00 =r(1:max_iterations, 1);
b = bar(xs, ys_00);
plot(xs, ys_00);
ylim([0 num_devices]);
xlabel("Iterations");
ylabel("Number of selected clients");
legend({'B', ...
}, ...
'location', 'northwest');
set(gca,'XMinorTick','on','YMinorTick','on');
grid on;
TextFontSize=20;
LegendFontSize = 15;
set(0,'DefaultAxesFontName','Times',...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',6);
set(gca,'FontName','Times New Roman','FontSize',TextFontSize);
hold off;
clear;
figure;
clf('reset');
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 6 日
What is getting missed?
Brave A
Brave A 2022 年 8 月 6 日
I need them as a curve all values in one line.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2022 年 8 月 6 日
Your data is not at all in pairs. Your data is in groups of 10 -- the data starts at 0 and returns to 0 each 10 entries.
You take the mean() over the first column, which I am guessing means that you want the mean over each group of 10.
Your legends and titles do not give me confidence that they are at all related to the input data.
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1089470/40_3_1.txt';
TextFontSize=20;
LegendFontSize = 15;
set(0,'DefaultAxesFontName','Times',...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',6);
set(gca,'FontName','Times New Roman','FontSize',TextFontSize);
max_iterations = 500;
xs = 1 : max_iterations;
num_devices=50;
N = readmatrix(filename, 'delimiter', '\t');
r = mean(reshape(N,10,[]), 1);
r = r';
ys_00 = r(1:max_iterations, 1);
plot(xs, ys_00);
xlabel("Iterations");
ylabel("Number of selected clients");
legend({'B', ...
}, ...
'location', 'northwest');
set(gca,'XMinorTick','on','YMinorTick','on');
grid on;
  9 件のコメント
Brave A
Brave A 2022 年 8 月 6 日
TextFontSize=20;
LegendFontSize = 15;
set(0,'DefaultAxesFontName','Times',...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',6);
set(gca,'FontName','Times New Roman','FontSize',TextFontSize);
max_iterations = 500;
xs = 1 : max_iterations;
num_devices=50;
N = readmatrix('40_3_1.txt', 'delimiter', '\t');
r = mean(reshape(N,10,[]), 1);
r = r';
ys_00 = r(1:max_iterations, 1);
plot(xs, ys_00);
xlabel("Iterations");
ylabel("Number of selected clients");
legend({'B', ...
}, ...
'location', 'northwest');
set(gca,'XMinorTick','on','YMinorTick','on');
grid on;
I have this right now. it's plot empty figure.:(
Walter Roberson
Walter Roberson 2022 年 8 月 6 日
Tested in R2021a Pre-release, code exactly as follows.
I am currently installing R2022a for testing.
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1089470/40_3_1.txt';
TextFontSize=20;
LegendFontSize = 15;
set(0,'DefaultAxesFontName','Times',...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',6);
set(gca,'FontName','Times New Roman','FontSize',TextFontSize);
max_iterations = 500;
xs = 1 : max_iterations;
num_devices=50;
N = readmatrix(filename, 'delimiter', '\t');
r = mean(reshape(N,10,[]), 1);
r = r';
ys_00 = r(1:max_iterations, 1);
plot(xs, ys_00);
xlabel("Iterations");
ylabel("Number of selected clients");
legend({'B', ...
}, ...
'location', 'northwest');
set(gca,'XMinorTick','on','YMinorTick','on');
grid on;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by