How to assign a symbolic equation to previously defined numeric matrix?

조회 수: 1 (최근 30일)
Mehdi
Mehdi 2022년 9월 18일
편집: Torsten 2022년 9월 18일
I have a vector that at the first stage it contains numeric values, but later must be assigned by symbolic equations. How is it possible in Matlab?
As a short example:
clear
syms eta__2 zeta__2
Wxy2(1)=1;
Wxy2(1) = legendreP(1, zeta__2)*legendreP(1, eta__2) ;
Unable to perform assignment because value of type 'sym' is not convertible to 'double'.

Caused by:
Error using symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
  댓글 수: 5
Mehdi
Mehdi 2022년 9월 18일
clear
syms eta__2 zeta__2
sym('Wxy2')=[0, 0, 0];
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
for r=1:3
for i=1:11
for j=1:11
Wxy2(r) =legendreP(i, zeta__2)*legendreP(j, eta__2) + Wxy2(r);
end
end
end
Torsten
Torsten 2022년 9월 18일
편집: Torsten 2022년 9월 18일
syms eta__2 zeta__2
Wxy2 = sym('Wxy2',[1 3]);
Wxy2(1:3) = sym('0');
for r=1:3
for i=1:11
for j=1:11
Wxy2(r) =legendreP(i, zeta__2)*legendreP(j, eta__2) + Wxy2(r);
end
end
end
Wxy2
Wxy2 = 

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by