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
Value assigned to variable might be unused error
9 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1252352/image.png)
Answers (1)
Steven Lord
on 4 Jan 2023
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."
0 Comments
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!