Error converting expression in double array
古いコメントを表示
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 件のコメント
Walter Roberson
2020 年 4 月 29 日
We do not know the datatypes of your various arrays. For example, assigning sym zeros into epsilon_s_2 does not force epsilon_s_2 to be symbolic unless it did not happen to exist before.
I suspect your epsilon_s_2 was not initialized to symbolic.
Prathamesh Khorgade
2020 年 4 月 29 日
Walter Roberson
2020 年 4 月 29 日
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.
Prathamesh Khorgade
2020 年 4 月 30 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Conversion Between Symbolic and Numeric についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!