How to write a symbolic expression to an array
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to write a function to calculate the normalisation factors for the first n_max eigen-functions of an eigen-problem. I want the function output, unperturbed_eig, to be a list of the normalisation factors, partition(k), which I have already calculated, multiplied by the eigenfunctions themselves. The eigenfunctions are symbolic expressions dependent on k, which is the eigenfunction number, and change if k is odd or even. The eigenfunctions are also dependent on x which I want to remain as a symbolic variable. However, I am struggling to create a list of the eigenfunctions and their normalisation factors when I have to evaluate k and keep x as symbolic. So far I have:
if true
% code
normalised_eig=zeros(n_max,1);
syms x
for k=1:n_max
if mod(k,2)==1
normalised_eig(k)=double((1/partition(k))*cos(k*pi*x/a));
else
normalised_eig(k)=double((1/partition(k))*sin(k*pi*x/a));
end
end
clear x
unperturbed_eig=normalised_eig;
end
I've also tried using the fprintf and sprintf but to no avail. How can I do this?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!