이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.
algorithm
클래스: slmetric.metric.Metric
네임스페이스: slmetric.metric
(제거 예정) 지표 데이터 분석을 위한 논리 지정
Metrics Dashboard 사용자 인터페이스, metricdashboard
기능, slmetric
패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.
설명
메트릭 알고리즘 분석을 위한 논리를 지정합니다. 사용자 정의된 메트릭 알고리즘은 라이브러리 링크 및 외부 MATLAB 파일 구성요소에 대해 호출되지 않습니다.
입력 인수
Metric
— 새로운 모델 메트릭 클래스
slmetric.metric.Metric
개체
새 메트릭에 대해 정의하는 모델 메트릭 클래스입니다.
Component
— 메트릭 분석용 구성요소
Advisor.component.Component
개체
메트릭 분석을 위한 Advisor.component.Component
의 인스턴스입니다.
출력 인수
Result
— 알고리즘 결과 데이터
slmetric.metric.Result
객체 배열
알고리즘 데이터로, slmetric.metric.Result
객체의 배열로 반환됩니다.
예제
비가상 블록 수에 대한 지표 알고리즘 생성
이 예에서는 algorithm
방법을 사용하여 비가상 블록 수 메트릭을 생성하는 방법을 보여줍니다.
createNewMetricClass
함수를 사용하여 nonvirtualblockcount
라는 이름의 메트릭 클래스를 생성합니다. 이 함수는 현재 작업 폴더에 nonvirtualblockcount.m
파일을 생성합니다.
className = 'nonvirtualblockcount';
slmetric.metric.createNewMetricClass(className);
메트릭 알고리즘 파일 nonvirtualblockcount.m
를 열고 편집합니다. 파일에 빈 메트릭 알고리즘 방법이 포함되어 있습니다.
edit(className);
다음 코드를 복사하여 nonvirtualblockcount.m
파일에 붙여넣습니다. nonvirtualblockcount.m
를 절약하세요. 이 코드는 비가상 블록 수를 계산하기 위한 메트릭 알고리즘을 제공합니다.
classdef nonvirtualblockcount < slmetric.metric.Metric % nonvirtualblockcount calculate number of non-virtual blocks per level. % BusCreator, BusSelector and BusAssign are treated as non-virtual. properties VirtualBlockTypes = {'Demux','From','Goto','Ground', ... 'GotoTagVisibility','Mux','SignalSpecification', ... 'Terminator','Inport'}; end methods function this = nonvirtualblockcount() this.ID = 'nonvirtualblockcount'; this.Version = 1; this.CompileContext = 'None'; this.Description = 'Algorithm that counts nonvirtual blocks per level.'; this.ComponentScope = [Advisor.component.Types.Model, ... Advisor.component.Types.SubSystem]; end function res = algorithm(this, component) % create a result object for this component res = slmetric.metric.Result(); % set the component and metric ID res.ComponentID = component.ID; res.MetricID = this.ID; % use find_system to get all blocks inside this component blocks = find_system(getComponentSource(component), ... 'FollowLinks','on', 'SearchDepth', 1, ... 'Type', 'Block', ... 'FollowLinks', 'On'); isNonVirtual = true(size(blocks)); for n=1:length(blocks) blockType = get_param(blocks{n}, 'BlockType'); if any(strcmp(this.VirtualBlockTypes, blockType)) isNonVirtual(n) = false; else switch blockType case 'SubSystem' % Virtual unless the block is conditionally executed % or the Treat as atomic unit check box is selected. if strcmp(get_param(blocks{n}, 'IsSubSystemVirtual'), ... 'on') isNonVirtual(n) = false; end case 'Outport' % Outport: Virtual when the block resides within % any SubSystem block (conditional or not), and % does not reside in the root (top-level) Simulink window. if component.Type ~= Advisor.component.Types.Model isNonVirtual(n) = false; end case 'Selector' % Virtual only when Number of input dimensions % specifies 1 and Index Option specifies Select % all, Index vector (dialog), or Starting index (dialog). nod = get_param(blocks{n}, 'NumberOfDimensions'); ios = get_param(blocks{n}, 'IndexOptionArray'); ios_settings = {'Assign all', 'Index vector (dialog)', ... 'Starting index (dialog)'}; if nod == 1 && any(strcmp(ios_settings, ios)) isNonVirtual(n) = false; end case 'Trigger' % Virtual when the output port is not present. if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'off') isNonVirtual(n) = false; end case 'Enable' % Virtual unless connected directly to an Outport block. isNonVirtual(n) = false; if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'on') pc = get_param(blocks{n}, 'PortConnectivity'); if ~isempty(pc.DstBlock) && ... strcmp(get_param(pc.DstBlock, 'BlockType'), ... 'Outport') isNonVirtual(n) = true; end end end end end blocks = blocks(isNonVirtual); res.Value = length(blocks); end end end
버전 내역
R2016a에 개발됨R2022a: Metrics Dashboard이 제거됩니다
Metrics Dashboard 사용자 인터페이스, metricdashboard
기능, slmetric
패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)