How to write a symbolic expression to an array

2 views (last 30 days)
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?

Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!