How to find location of parameters in a genarized matrix

조회 수: 4 (최근 30일)
Fredrik Smith
Fredrik Smith 2021년 9월 21일
답변: Ayush Aniket 2024년 10월 28일
I want to find the location of tunable parameters within a generalized matrix.
I want to make sure I don't miss parameters with values set to zero, so converting to double won't work.
Is this possible?
For example:
p = realp('p', 0);
A = genmat(zeros(5));
A(2,4) = p;
% now find the location of p in A

답변 (1개)

Ayush Aniket
Ayush Aniket 2024년 10월 28일
There is no MATLAB function that would provide you the location of these tunable parameter within the generalized matrix. However, if the goal is to interact and change the value of these paramters, you can use the Blocks propoerties of the matrix. Refer to the following documentation link to read about the property:
If you need the location of the parameters, a hackish workaround is to use the usubs function to substitute the tunable parameters with unique identifiers and then identify their locations as shown below:
p = realp('p', 0);
A = genmat(zeros(5));
A(2,4) = p;
% Substitute the tunable parameter with a unique value
% This helps in identifying the location of the parameter
uniqueValue = 1; % Use a unique non-zero value
A_sub = usubs(A, 'p', uniqueValue);
% Find the location of the unique value
[row, col] = find(A_sub == uniqueValue);

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by