setValues
Description
Examples
Open the sdoCSTR model and create a gridded parameter space for model parameters A and h.
mdl = "sdoCSTR"; open_system(mdl); p = sdo.getParameterFromModel(mdl,{'A','h'}); gs0 = sdo.GriddedSpace(p)
gs0 =
GriddedSpace with properties:
ParameterValues: {{1×3 cell} {1×3 cell}}
Notes: []
Spaces: {1×0 cell}
ParameterNames: {'A' 'h'}
Options: [1×1 sdo.GriddingOptions]
Because you do not specify allowed grid values for the two parameters, sdo.GriddedSpace assigns the default values: 10% less than the parameter nominal value, the nominal value, and 10% more than the nominal value. Change the allowed values for both parameters to a specified set.
Avals1 = {0.2 0.6 1.0 1.4 1.8 2.2};
hvals1 = {0.5 1.5 2.5 3.5};
gs1 = setValues(gs0,p,{Avals1,hvals1})gs1 =
GriddedSpace with properties:
ParameterValues: {{1×6 cell} {1×4 cell}}
Notes: []
Spaces: {1×0 cell}
ParameterNames: {'A' 'h'}
Options: [1×1 sdo.GriddingOptions]
setValues replaces the allowed values for both parameters with the new sets of values.
Now, set new values for the parameter h only. This time, specify the parameter by its name instead of by a parameter object.
hvals2 = {0.2 0.5 1.0 1.2 1.8};
gs2 = setValues(gs0,'h',{hvals2})gs2 =
GriddedSpace with properties:
ParameterValues: {{1×3 cell} {1×5 cell}}
Notes: []
Spaces: {1×0 cell}
ParameterNames: {'A' 'h'}
Options: [1×1 sdo.GriddingOptions]
Here, setValues replaces the allowed values for h with the new set of values.
Input Arguments
Gridded parameter space in which to set parameter values, specified as an
sdo.GriddedSpace object.
Parameters to update in gs0, specified as one of the
following:
Character vector, cell array of character vectors, or string containing the names of the parameters to update in
gs0. For example,'A1',{'A1','A2'}, or"A1".param.Continuousobject,param.Discreteobject, or vector of parameter objects. Usually, you obtain these objects usingsdo.getParameterFromModelorsdo.getStateFromModel.
Parameter values for gridded sampling, specified as a cell array of cell arrays
providing the allowed values for each parameter in p. For instance,
if p contains two parameters, one that can take values (1, 2, 3)
and another that can take values (10, 20, 30), then use values =
{{1,2,3},{10,20,30}}. Use this argument when adding parameters for gridded
sampling to an sdo.GriddedSpace object.
Output Arguments
Version History
Introduced in R2023a
See Also
sdo.GriddedSpace | addParameter | removeParameter | sdo.getParameterFromModel
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)