Creating a Simbolic vector and setting assumptions on it
2 views (last 30 days)
Show older comments
Francesco Giuseppe Fornari on 8 Aug 2019
Commented: Francesco Giuseppe Fornari on 13 Aug 2019
I'm trying to build a symbolic vector with variable dimension N, and I would like it to be real...
I managed to build the vector with the desired lenght throug str2sym, but I don't know how to set assumption "real" on its variables.
(I would like to use this vector for a linear system).
A = i;
s1=sprintf(' u%d, ',A);
s2=sprintf(' v%d, ',A);
s3=sprintf(' w%d ',A);
stot2=strcat(stot2, s1, s2, s3);
U1=['[' stot2 ']'];
Thanks for any help!
u = sym('u', [1 N], 'real');
v = sym('v', [1 N], 'real');
w = sym('w', [1 N], 'real');
U = [u, v, w];
More Answers (1)
Divya Gaddipati on 12 Aug 2019
You can declare assumptions on symbolic variables using the assume function from the Symbolic Math Toolbox. For more information on how to use this function, refer to this link.
In your code, since “U” is a sym object, you can directly loop over U and set each of the variable to real.
for i = 1 : length(U)
Find more on Semiconductors and Converters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!