norm inbuilt function code
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I am trying to find the code for the inbuilt function norm, but, by typing "open norm" I would only find a script describing it, not the code. I need to write the m file as funtion in order to add it in my folder with the other functions (for instance deg2rad which is another but its code is aveilable by typing "open deg2rad")
채택된 답변
dpb
2018년 4월 10일
0 개 추천
That's how all builtin functions work in Matlab, that's why they're "built in"; the working part of the function is compiled code built into the executable for the program. Core functionality is incorporated in that manner to improve performance; other routines are just supplied m-code no different than user-written as far as their implementation. There are also p-code and mex files...
Why do you think you need to include the function in some other location; there really is no reason to do that in general. Occasionally one will take a specific m-file and create a slightly modified version for a specific purpose, but it's highly recommended to make the user copy distinct and to not modify nor alias actual distributed functions.
댓글 수: 6
If i don't include the function I keep get the message "undefined function", I don't know the reason but that's why I think I need that, any suggestion? Thank you!
James Tursa
2018년 4월 10일
편집: James Tursa
2018년 4월 10일
Post the code you are using, and copy & paste the entire error message for us to see. It could be you are calling norm( ) with a non-numeric input argument.
Guillaume
2018년 4월 10일
The core problem has nothing to do with the code for norm but we don't know what the core problem is. As James says, show us the real problem.
Francesco Fortunato
2018년 4월 10일
편집: Walter Roberson
2018년 4월 10일
The portion of the code (which is truly long) involved is
%%Add Node callback Subfunction
function addnode(hObject, EventData )
global guihandles cmenus input
import javax.swing.*
if ischar(hObject)
objlabel = hObject;
childrens = 0;
else
objlabel = get(hObject,'Label');
childrens = get(hObject,'Children');
end
if ~norm(childrens)
switch objlabel
case 'Orbit'
if ~isfield(guihandles.nodehandles,'orbit')
%Creo un nodo 'Orbit', lo aggiungo e aggiorno
guihandles.nodehandles.orbit = javax.swing.tree.DefaultMutableTreeNode();
% icon = javax.swing.ImageIcon('logo.png')
% guihandles.nodehandles.orbit.setUserObject(JLabel('a',icon,0))
guihandles.nodehandles.orbit.setUserObject(objlabel);
guihandles.nodehandles.root.add(guihandles.nodehandles.orbit);
guihandles.albero.updateUI;
guihandles.htextbox.append( ['Orbit added to the Simulation Tree',guihandles.newline ]);guihandles.htextbox.setCaretPosition(guihandles.htextbox.getText.length);
%Add subguihandles.menus to Orbit Menu
guihandles.menus.earth = uimenu( guihandles.menus.orb ,'Label','Aspherical Gravity Field','Callback',{@addnode});
guihandles.cmenus.earth = uimenu( guihandles.cmenus.orb ,'Label','Aspherical Gravity Field','Callback',{@addnode});
guihandles.menus.third = uimenu( guihandles.menus.orb ,'Label','Third Body Perturbation','Callback',{@addnode});
guihandles.cmenus.third = uimenu( guihandles.cmenus.orb ,'Label','Third Body Perturbation','Callback',{@addnode});
guihandles.menus.drag = uimenu( guihandles.menus.orb ,'Label','Atmospheric Drag','Callback',{@addnode});
guihandles.cmenus.drag = uimenu( guihandles.cmenus.orb ,'Label','Atmospheric Drag','Callback',{@addnode});
guihandles.menus.srp = uimenu( guihandles.menus.orb ,'Label','Solar Radiation Pressure','Callback',{@addnode});
guihandles.cmenus.srp = uimenu( guihandles.cmenus.orb ,'Label','Solar Radiation Pressure','Callback',{@addnode});
guihandles.menus.thrstr = uimenu( guihandles.menus.orb ,'Label','Thrusting Strategy','Callback',{@addnode});
guihandles.cmenus.thrstr = uimenu( guihandles.cmenus.orb ,'Label','Thrusting Strategy','Callback',{@addnode});
else
guihandles.htextbox.append( ['Orbit Node has already been added to the Simulation Tree',guihandles.newline ]);guihandles.htextbox.setCaretPosition(guihandles.htextbox.getText.length);
end
The error message arises when clicking on one menu in the GUI
Undefined function 'norm' for input arguments of type 'matlab.ui.container.Menu'.
Error in filename>addnode (line 2485)
if ~norm(childrens)
Error while evaluating Menu Callback
You focused on the wrong part of the error message. It's not that it's undefined, it's that it's not defined for inputs of type matlab.ui.container.Menu. Indeed, what do you expect the norm of a menu to be?
Clearly the problem is not with norm, the problem is with the line
if ~norm(childrens)
which makes no sense.
dpb
2018년 4월 10일
As James surmised, it's not that the code for norm is missing; it's that you're calling it with something other than a numeric input...read the message carefully:
Undefined function 'norm' for input arguments of type 'matlab.ui.container.Menu'.
You've got to dereference the GUI object to get the content thereof; I'm no GUI kinda' guy to even have a clue what a matlab.ui.container is or would look like, but certainly a Menu of one won't be anything meaningful to take the norm of...
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
