parse error at '=': usage might be invalid matlab syntax

12 views (last 30 days)
Dear colleagues,
I wrote the following code for a function, but when I run it, there is an error at Command Window that tells me the following message:
>> Metodo_Caracteristicas_2
Error: File: Metodo_Caracteristicas_2.m Line: 14 Column: 37
The expression to the left of the equals sign is not a valid target for an assignment.
I will would greatly appreciate who helps me, thank you.
Parse error at '=':usage might be invalid MATLAB syntax
  9 Comments
Walter Roberson
Walter Roberson on 4 Mar 2020
Well, that kind of line with an expression and then "=" and then another expression, is valid in C only to the extent that the person is coding an inline assignment statement in a confusing manner. For example in C,
A + B = 1 + C;
is valid and is to be interpreted as:
calculate or retrieve A and pull it into memory
assign 1 to variable B and pull the resulting value into memory
do the addition of those two items in memory, leaving the result in memory
calculate or retrieve C and pull the resulting value into memory
do the addition of those two items in memory, leaving the result in memory
discard the result in memory
In your case, it would be P_I[i][n] that would be assigned into in both lines. It is unlikely that that would be what you would want to do.
If you can rewrite the lines the way you would code them in C, there is a good chance we could tell you how they would then be coded in MATLAB.
Pablo Silvoni
Pablo Silvoni on 4 Mar 2020
Dear Walter,
Thank you again for your kind attention and soon answer to my questions.
I haven't programmed in matlab for a long time and I do this mistakes.
I will write my C code and I will share with you it to try rewrite it in Matlab code.
Thank you again.
Pablo

Sign in to comment.

Answers (0)

Categories

Find more on Function Creation 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!