필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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

채택된 답변

albara
albara 2023년 4월 29일
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
Walter Roberson
Walter Roberson 2023년 4월 30일
ini is created by
ini = ini2struct('config.ini')
so the implication is that SENDERS should be part of config.ini
Walter Roberson
Walter Roberson 2023년 4월 30일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by