why does it not work on my matlab this example from the book
조회 수: 1 (최근 30일)
이전 댓글 표시
Here are an example with matlab elseif and my attempt to rewrite it without success:
This is my script:
y=calcy(x)
if x<-1
y=1;
elseif x<=2
y=x^2;
else
y=4;
end
end
And why do they need two end. What are the two things they are ending?
댓글 수: 0
채택된 답변
David Young
2011년 10월 15일
The second end is the end of the function. If you run the code outside a function, you must omit it.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!