Error converting expression in double array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Inspite of defining a column of matrix as symbolic using 'syms', MATLAB gives the same error, that it cannot convert eypression to double.
A part of the code goes somewhat like this (for a start i can be taken equal to P1):
epsilon_s_2(i-P1+2,1:151) = sym (zeros (1,151));
Fs(1:151,1) = sym (zeros (151,1));
for j=1:50000 % Limiting the inner iterations to 50000
if L<=1.5
syms x positive
epsilon_p_a2(i-P1+2,1)= epsilon_p_a2(i-P1+1,1); % Force finding in prestressing cable
Fp (((L-L_ung)/0.1)+1,1)= Ecfk_p*Ap*epsilon_p_a2(i-P1+2,1);
epsilon_s_2(i-P1+2,(round (L/0.1))+1) = ((ds/x) -1) * epsilon_c_2(i-P1+2,(round (L/0.1))+1);
4 commentaires
Walter Roberson
le 29 Avr 2020
AAA = [0 0 0]; %initialize as double
AAA(2) = sym(3); %put a symbolic number in there
AAA %show the content
class(AAA) %did AAA become symbolic?
syms x
AAA(2) = x; %we assigned AAA(2) to symbolic value. Can we now store symbolic variables into there?
BBB = sym([0 0 0]); %initialize as symbolic
BBB(2) = sym(3); %put a symbolic number in there
BBB %show the content
class(BBB) %is BBB (still) symbolic ?
syms x
BBB(2) = x; %we assigned BBB(2) to symbolic value. Can we now store symbolic variables into there?
When you have a double() array, then when you assign sym() of a numeric value into the array, the symbolic number is converted into double precision and the double precision is stored; the array does not suddenly become symbolic. And because it is not changed to symbolic when you assign a symbolic numeric value into part of it, then it is still not symbolic later when you try to assign an expression involving x into it, where x is a symbolic variable that has not been asssigned a numeric value.
Réponses (0)
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!