Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parenthe

14 views (last 30 days)
I don't understand this mistake
File: funcion.m Line: 1 Column: 18
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other
syntax error. To construct matrices, use brackets instead of parentheses.
>> function funcion('grid1000.dat',1833;1005;'01'), (columna1)
if nx/10~=floor(nx/10) % se cumple si nx es multiplo de 10 (columna18)
  2 Comments
Les Beckham
Les Beckham on 4 Mar 2024
Edited: Les Beckham on 4 Mar 2024
Have you shown the contents of funcion.m or the call to the function that you entered on the command line?
In either case, you can't use semicolons in either a function definition or a function call argument list. Use commas to seperate the arguments.
Please attach funcion.m using the paper clip icon if you still need help after changing those semicolons to commas.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 5 Mar 2024
You cannot define functions at the command line.
When you do define functions, you must provide a list of plain (unindexed) variables, not values. You would provide the values when you call the function.

Steven Lord
Steven Lord on 5 Mar 2024
>> function funcion('grid1000.dat',1833;1005;'01'), (columna1)
You cannot type a function definition in the MATLAB Command Window. [I'm deliberately ignoring anonymous functions for purpose of this explanation.] You need to define it in a file.
But even if you had put this in a file, you're mixing how you define a function and how you call a function. See this documentation page for a description of how to define a function. The input arguments in your definition must be variable names, and when the person who wants to use your function calls it the data they pass into the function will be known in the function's workspace by the names you used in the definition.
So if you'd defined:
function myfunction(a, b, c)
and I call it:
myfunction(4, 5, 6)
inside myfunction, whenever you use the variable a it has the value 4. Similarly the variable b will have the value 5 and the variable c will have the value 6.
And when you either define or call a function, separate the variable names (define) or values (call) with commas.

Categories

Find more on Cell Arrays 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!