필터 지우기
필터 지우기

How to end code folding

조회 수: 1 (최근 30일)
Mohamad Roslan Mohd Roshdi
Mohamad Roslan Mohd Roshdi 2016년 1월 22일
댓글: Mohamad Roslan Mohd Roshdi 2016년 1월 23일
Dear friend I'm new to Matlab and have zero coding experience I had this problem as i want to write new command
It keep written under that function loop, I tried to use 'end', but return error as Illegal use of reserved keyword "end"
How to exit the code folding for the function and start new command line?
*sorry for my english
  댓글 수: 2
Stephen23
Stephen23 2016년 1월 22일
편집: Stephen23 2016년 1월 22일
code folding does not change the code itself, it only changes how the code is displayed. The error message tells you that you have written something wrong with your code, but the code folding cannot fix it, just show it, or hide it.
Try clicking on the small + symbol on the left-hand side of the editor to unfold the code (i.e. to see more of the code).
If you upload the code then we can tell you what is causing the error.
Mohamad Roslan Mohd Roshdi
Mohamad Roslan Mohd Roshdi 2016년 1월 22일
% --- Executes on button press in Apply.
function Apply_Callback(hObject, eventdata, handles)
% hObject handle to Apply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mAs=(floor(mA))
Above it the code generated from GUI builder I try to write another code but it always end up being under Apply_Callback function.
How do I write code outside Apply_Callback function?

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

채택된 답변

Image Analyst
Image Analyst 2016년 1월 22일
If you want a new function that is not to be considered as part of the Apply_Callback() function, then you need to use the "function" keyword:
function Apply_Callback(hObject, eventdata, handles)
% code for Apply_Callback()
% Now define your new function:
function mAs = MyNewFunction(ma)
mAs=(floor(mA));
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 1월 23일
Note that it is not possible in MATLAB to have a file that has both functions and "command line" (scripts). In a function file, everything has to be in a function.
Mohamad Roslan Mohd Roshdi
Mohamad Roslan Mohd Roshdi 2016년 1월 23일
I see, that explain everything. No wonder it keep trying to take my code under one of those function
Thank you :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by