How to find location of parameters in a genarized matrix

3 Ansichten (letzte 30 Tage)
Fredrik Smith
Fredrik Smith am 21 Sep. 2021
Beantwortet: Ayush Aniket am 28 Okt. 2024 um 8:52
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

Antworten (1)

Ayush Aniket
Ayush Aniket am 28 Okt. 2024 um 8:52
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);

Kategorien

Mehr zu Portfolio Optimization and Asset Allocation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by