Is it possible to extract the contents of a generalised matrix after it has been created with tunable parameters?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
After creating a generalised matrix (genmat) from tunable parameters (realp) can the dependencies of the genmat on the realp be determined exactly, for example in the form of a function handle? Using the example from the genmat documentation
a = realp('a',-1);
b = realp('b',3);
M = [1 a+b;0 a*b]
Is it possible to determine exactly how to generate M in terms of a and b (by e.g. creating a function handle (or symbolic expression) for only the object M)?
Obviously it would be possible to sample different values of a and b but I'm interested in an exact expression, surely this information is contained somewhere in the genmat M object?
0 comentarios
Respuestas (1)
Nithin Kumar
el 5 de Sept. de 2023
Hi Fredrik,
I understand that you want to extract the contents of a generalized matrix after it has been created with tunable parameters.
To determine the exact dependencies of a generalized matrix (genmat) on tunable parameters (realp), kindly refer to the following example:
1. Define symbolic variables for your tunable parameters using "syms":
syms realp1 realp2 realp3;
2. Define your generalized matrix, "genmat" as a symbolic expression using these symbolic variables and perform any mathematical operations as needed:
genmat = [realp1^2, realp1 + realp2; realp3, realp2^2];
3. Now, you can determine the exact dependencies by differentiating "genmat" with respect to each "realp":
dependency_realp1 = diff(genmat, realp1);
dependency_realp2 = diff(genmat, realp2);
dependency_realp3 = diff(genmat, realp3);
These "dependency_realpX" expressions represents the exact mathematical dependencies of "genmat" on each tunable parameter, and you can use them as function handles if needed.
Kindly refer to the following code snippet to create a function handle:
genmat_function = matlabFunction(genmat, 'Vars', {realp1, realp2, realp3});
dependency_realp1_function = matlabFunction(dependency_realp1, 'Vars', {realp1, realp2, realp3});
dependency_realp2_function = matlabFunction(dependency_realp2, 'Vars', {realp1, realp2, realp3});
dependency_realp3_function = matlabFunction(dependency_realp3, 'Vars', {realp1, realp2, realp3});
Now, you can use these function handles to evaluate "genmat" and its dependencies for specific values of "realp1", "realp2", and "realp3".
For more information regarding "syms", kindly refer to the following documentation:
I hope this provides you with the required information regarding your query.
Regards,
Nithin Kumar.
0 comentarios
Ver también
Categorías
Más información sobre Chebyshev en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!