Borrar filtros
Borrar filtros

Unrecognized function or variable 'printstat'. Error in manet (line 162) if printstat == 1

1 visualización (últimos 30 días)
Getting Unrecognized function or variable 'printstat'. error. Please can anyone help? Thanks.
%% print statistics
if printstat == 1
simstat(ini.globals.SIMTIME,Nodes,ini.globals.SENDERS,ini.globals.RECEIVERS,Protocols,Apps);
end

Respuesta aceptada

albara
albara el 29 de Abr. de 2023
It looks like you're trying to use the variable printstat in your MATLAB script but it hasn't been defined yet. That's why you are getting the error "Unrecognized function or variable 'printstat'." To fix this error, you need to define the variable printstat before using it in the conditional statement.
For example, if you want to use the printstat variable as a flag to decide whether to print statistics or not, you can set it to 1 (true) or 0 (false). Add the following line before the conditional statement:
printstat = 1; % Set printstat to 1 (true) to print statistics, 0 (false) otherwise
Your updated code should look like this:
printstat = 1; % Set printstat to 1 (true) to print statistics, 0 (false) otherwise
%% print statistics
if printstat == 1
simstat(ini.globals.SIMTIME,Nodes,ini.globals.SENDERS,ini.globals.RECEIVERS,Protocols,Apps);
end
Now your script should run without encountering the "Unrecognized function or variable 'printstat'" error.
Waiting for your feedback
Important: There may be some mistakes in this answer Experts can tell if there are any mistakes
  8 comentarios
Walter Roberson
Walter Roberson el 30 de Abr. de 2023
ini is created by
ini = ini2struct('config.ini')
so the implication is that SENDERS should be part of config.ini
Walter Roberson
Walter Roberson el 30 de Abr. de 2023
The code expects to use ini.globals.SENDERS but the config.ini file defines SENDERS in the constants section, ini.constants.SENDERS
The config.ini file defines printstats in the visuals section, so the reference should be to ini.visuals.printstats

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by