I am receiving a "Parse error at '=' ..." whenever trying to assign a value to a variable
Show older comments
I was editing a script that worked fine until at certain point I tried to assign a new value to a variable and received a "Parse error at '=' ..." whenever trying to assign a value to an arg:
nstr = 0.89 % MPa nominal stress
the ewual sign underlined red for error and a mouse pointer hovered over it the error message would pop up:
"Parse error at '=' usage ight be invalid in MATLAB syntax:
When I attempted running the script the error message in command window would be:
Error: File: ImportEMData_021.m Line: 40 Column: 8
Unsupported use of the '=' operator. To compare values for equality, use '=='. To specify name-value
arguments, check that name is a valid identifier with no surrounding quotes.
This is the first instance of nstr in the script.
I have checked to confirm that nstr is not used as a function call in Matlab 2024a (negative) then, just on case changed the variable name (found/replaced all isntances to
nomStr = 0.89 % MPa
Then tried in some other part of the script
A =
and as soon as the equal sign would be added the error pops up...
Please advise
Lech
Answers (1)
There is likely something incorrect somewhere in the preceding code, e.g.:
ohno = [... <- missing closing bracket.
... more code
nstr = 0.89 % MPa nominal stress
Either:
- debug this yourself
- if you want us to help debug it for you then please show us the complete code e.g. by uploading the script by clicking the paperclip button oy by posting the code in a comment.
2 Comments
Lech Muszynski
on 15 Apr 2024
Moved: Rik
on 15 Apr 2024
Steven Lord
on 15 Apr 2024
One thing that can help identify this type of problem is to Smart Indent the code. Once you've done that, look for places where a line doesn't start in the column that you expected it to start, but started in a different column (usually further right.)
Categories
Find more on Structured Data and XML Documents 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!