issues with plots with multiple information

I need to plot those information but it's show me "Error using plot
Vectors must be the same length."
All the information provided and text file.
clear;
clf('reset');
max_iterations = 1000;
xs = 1: max_iterations;
num_devices=50;
ys_00=importdata('NOMA_users.txt');
ys_01=importdata('NOMA_users.txt');
ys_02=importdata('NOMA_users.txt');
ys_00 =NOMA_users(1:max_iterations, 1);
Unrecognized function or variable 'NOMA_users'.
b = bar(xs, ys_00);
plot(xs, ys_00);
hold on;
plot(xs, ys_01);
plot(xs, ys_02);
ylim([0 num_devices]);
title({title_text_1; title_text_2; title_text_3})
xlabel("Iterations");
ylabel("Number of selected clients");
% legend({'Number of selected clients by LEARN ', ...
% 'LEARN (after energy filtering)', ...
% 'GREED'}, ...
% 'location', 'northwest');
% set(gca,'XMinorTick','on','YMinorTick','on');
% grid on;
TextFontSize=25;
LegendFontSize = 20;
set(0,'DefaultAxesFontName','Times',...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',6);
set(gca,'FontName','Times New Roman','FontSize',TextFontSize);
hold off;
clear;
figure;
clf('reset');
plot(xs,ys1, '-bo');
ylim([0 num_devices]);
% title({title_text_1; title_text_2; title_text_3})
ylabel(ylabel_text_1);
xlabel('Mean value of $\mu_{i}$', 'interpreter', 'latex');

4 commentaires

Thats because the length are not the same. Send in the data, so I can see how to fix it
Brave A
Brave A le 19 Juil 2022
I already attached the text file which has 1000 values.
Brave A
Brave A le 20 Juil 2022
Any Ideas?
still get this messgae
Index in position 1 exceeds array bounds (must not exceed 599).

Connectez-vous pour commenter.

 Réponse acceptée

ys_00 =NOMA_users(1:max_iterations, 1);
NOMA_users does not exist as a function or variable in your code. You read in data from a file with that name, but you store the data in ys_00
We can speculate that in your real code you are doing
ys_00 = ys_00(xs, 1);
Later you plot xs vs ys_00 and that should work because they are the same length.
ys_01=importdata('NOMA_users.txt');
ys_02=importdata('NOMA_users.txt');
That is the same input file name as what you already read in.
Later you plot xs vs ys_01 but unlike with ys_00 you did not extract a subset of the file, so your x is length 1000 but your ys_01 is the full file of data. You probably need
ys_01 = ys_01(xs, 2);
or something similar, and likewise for ys_02

4 commentaires

Brave A
Brave A le 19 Juil 2022
Here is the data for ys_00, I attached them. Sorry still the code not working :(
Brave A
Brave A le 19 Juil 2022
Index in position 1 exceeds array bounds (must not exceed 599).
Error in Noma_compare (line 50)
ys_00 = ys_00(xs, 1);
Brave A
Brave A le 20 Juil 2022
Any Ideas?
Walter Roberson
Walter Roberson le 20 Juil 2022
Modifié(e) : Walter Roberson le 20 Juil 2022
use
ys_00 = importdata('NOMA_users.txt');
max_iterations = min(1000, size(ys_00,1));
xs = 1:max_iterations;
ys_00 = ys_00(xs, 1);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by