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

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

note each of those functions are on different lines!
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.

댓글을 달려면 로그인하십시오.

 채택된 답변

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개)

카테고리

도움말 센터File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

질문:

2016년 2월 7일

답변:

2016년 2월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by