Unexpected MATLAB expression.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rebecca Hadley
el 1 de Feb. de 2019
Respondida: Rebecca Hadley
el 5 de Feb. de 2019
Hi, I'm a MATLAB newbie and am really struggling with some code that has been given to me by a software company for importing BIN files containing acceleration data.
Can anyone help me with what the error means?
function [header, time, xyz, light, button, prop_val] = read_bin('CGGM.bin', varargin)
There is more to the code than the above, but the error seems to point to an issue with this line. Thanks in advance!
0 comentarios
Respuesta aceptada
OCDER
el 1 de Feb. de 2019
Editada: OCDER
el 1 de Feb. de 2019
function [header, time, xyz, light, button, prop_val] = read_bin('CGGM.bin', varargin)
^^^^^^^^^
You can't have a string as an input "parameter" name.
function [header, time, xyz, light, button, prop_val] = read_bin(Input1, varargin)
To input "CGGM.bin" as an input to your function, do this
>> [header, time, xyz, light, button, prop_val] = read_bin('CGGM.bin', ...)
2 comentarios
OCDER
el 2 de Feb. de 2019
You have a recursive summon, as in your script (read_bins) is trying to summon itself (read_bins). Make sure a script name is different from a function name. Look up the difference between script vs function for Matlab on the search engine
Example of a script called addScript.m
In1 = 2;
In2 = 3;
A = In1 + In2; %Note, there is no use of the word "function" in the code.
Example of a function called addFunc.m
function Out = addFunc(In1, In2)
A = In1 + In2; %Note, this is a "function" that accepts inputs "In1" and "In2".
To use a function, do this:
>> A = addFunc(2, 3)
To use a script, do as you did:
>> addScript
Overall, I'd stay away from using scripts, as it's used often as a temporary code for setting up equations, parameters, etc., before wrapping the code into a function.
Más respuestas (1)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!