主要内容

evaluateFeature

Class: mbcrunner

Evaluate feature in CAGE project with data set

Since R2024b

Description

[tbl,s] = evaluateFeature(obj,featureName,dataSource) evaluates the feature specified by featureName in the CAGE project specified by obj with the data specified by dataSource.

example

Input Arguments

expand all

Handle to the CAGE project, specified as an mbcrunner object.

Feature to evaluate, specified as a string scalar.

Data Types: string

Data source, specified as a table object or a string that specifies a filename.

Output Arguments

expand all

Raw data and the evaluated featured, returned as a table object. The evaluated feature data is returned in the last column of the table. If the raw data contains a variable with the same name as the feature, the last column is named <featureName>_Feature.

Root mean squared error (RMSE) of residuals, returned as a scalar.

Data Types: double

Examples

expand all

Using the characterizeBattery method, characterize the Battery Equivalent Circuit (Simscape Battery) block and evaluate a feature using a data set.

Create mbcrunner Object

Create a handle to a CAGE project.

r = mbcrunner;

Open Simulink Model

Open the Simulink model containing the Battery Equivalent Circuit block.

open("Simscape_BEC.slx");

Set the batteryBlock variable to the battery block path.

batteryBlock = "Simscape_BEC/Battery Equivalent Circuit";

Characterize Battery Cell

Characterize the battery using the data files located in the folder HPPC_data/origPreprocessedData. Set the number of iterations for the battery characterization process to 25.

[tbls,sfit] = characterizeBattery( ...
    r,batteryBlock,fullfile(pwd,'HPPC_data','origPreprocessedData'), ...
    NumIterations=25,ShowProgress=false);

Preview the open circuit voltage table.

surf(SOC_vec,Temperature_vec,tbls.OCV');
xlabel('SOC');ylabel('Temperature');zlabel('OCV Table');

Figure contains an axes object. The axes object with xlabel SOC, ylabel Temperature contains an object of type surface.

Evaluate Feature

Evaluate the Voltage3 feature using the hppcDataBAKcell0degC.mat data file.

[results,s] = evaluateFeature(r,"Voltage3", ...
    fullfile( ...
    pwd,'HPPC_data', 'origPreprocessedData','hppcDataBAKcell0degC.mat'));

Plot the voltage error to inspect the fit.

plot(results.voltage - results.Voltage3, '.');
ylabel('Error');
title(sprintf('Difference Between measured voltage and Voltage3 (RMSE: %.4f)', s));

Figure contains an axes object. The axes object with title Difference Between measured voltage and Voltage3 (RMSE: 0.0120), ylabel Error contains a line object which displays its values using only markers.

Version History

Introduced in R2024b