Value assigned to variable might be unused error

10 次查看(过去 30 天)
  2 个评论
Valters
Valters 2023-1-4
I tried to do something but variables not found, I done everything written but nothing changed, this error occurs to other my matlab document which line not working with this variables
Valters
Valters 2023-1-4
This is the problem I get when I try to run program with this variables

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2023-1-4
Note that this is not an error. This message is a Code Analyzer warning indicating that there may be a problem with this code. It may indicate that you made a typo on a later line (referring to a variable S1 when you intended to refer to the variable S defined on this line), that you computed something but then overwrote that result (preventing you from using that computed value later in your code), or indicating that you may not need the results of that computation (which may allow you to avoid computing it in your code, potentially saving time and/or memory.)
Or it could be that you intended to overwrite the result on a later line. Perhaps the only reason you needed to compute it is to display it in a report, for example.
If you know why you're assigning to that variable but not using it, you can suppress the Code Analyzer message by right-clicking on the underlined code. The context menu should have options to supress the warning, basically telling Code Analyzer "I know what's going on here, and it's okay." much like telling a barking dog "It's okay, that's just the mail carrier doing their job."

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by