not formed from a valid identifier; using the end function for a simple m file.

3 次查看(过去 30 天)
I am essentially copying the exact same code my prof used on powerpoint and yet the code keeps telling me this doesnt work. No matter what I put for the last line an error says " is not formed from a valid matlab identifier.
a=e^2
if a<x
disp ('a is less than x');
elseif a>x
disp ('a is greater than x');
end
[EDITED, Jan, code formatted]
  2 个评论
Jan
Jan 2016-2-7
编辑:Jan 2016-2-7
@Kyle: Please use the "{} Code" button to format code. Thanks.
If you post the complete error message, the readers do not have to guess in which line it appears.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2016-2-7
Please note that e and x are not predefined variables in MATLAB. If you want e to be the base of the natural logarithms then you would need to define it to be that,
e = exp(1)
e^2 in MATLAB would be written as exp(2)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by