Error: File: project_01.m Line: 61 Column: 26

4 views (last 30 days)
Wigton761
Wigton761 on 4 Sep 2015
Commented: Walter Roberson on 28 Jan 2023

having issues with making the if statement to be able to do the edge case extra credit. The error I get is: Error: File: project_01.m Line: 61 Column: 26 The expression to the left of the equals sign is not a valid target for an assignment.

I understand that Matlab doesn't recognize one of my variables but I don't understand why and how to fix it. I am trying to get the program to do if the length unrounded minus the length rounded is greater than .5 then the edge case will apply.

The portion of the script that is the issue is: (code is red comments are green)

Hexa_row_large = ceil(Hexa_column / 2); %{amount of rows not missing a hexagon%}

if(.5>(Hexa_number_unrounded-Hexa_number)) Hexa_number_small = Hexa_row_small * (Hexa_number); %{number of hexagons in small rows%}

elseif Hexa_number_small = Hexa_row_small * (Hexa_number - 1); %{number of hexagons in small rows%}

end Hexa_number_small = Hexa_row_small * (Hexa_number - 1); %{number of hexagons in small rows%}

Hexa_number_large = Hexa_row_large * Hexa_number; %{number of hexagons in large rows%}

The highlighted portion is the error mat lab is underlining.

Hexa_number = Number of Hexagons in the first row (rounded)

Hexa_row_large = The amount of Hexagons in the Large rows

Hexa_number_small = Number of Hexagons in the row with less Hexagons than the other

Hexa_number_unrounded = Number of Hexagons in the first row (unrounded)

  1 Comment
Wigton761
Wigton761 on 4 Sep 2015
I am trying to make the script choose one of two values depending on whether .5 is greater than those two values

Sign in to comment.

Answers (2)

Jerome Nathanie
Jerome Nathanie on 28 Jan 2023
File: solution.m Line: 13 Column: 61
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
  1 Comment
Walter Roberson
Walter Roberson on 28 Jan 2023
This does not appear to be a solution for the question that was asked.

Sign in to comment.


Walter Roberson
Walter Roberson on 28 Jan 2023
elseif Hexa_number_small = Hexa_row_small * (Hexa_number - 1);
elseif must be followed by a condition, not an assignment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!