Here is my code:
clearvars;
clc;
close all;
%Define the domain:
l=1;
%and consider, say, 4 periods
x=linspace(-4,4);
%Define the number of terms to consider
n_tot=50;
%Initialize the vectors containing each term of the series
FSS_term_x=zeros(n_tot,length(x));
%Loop to compute each term of the series up to n_tot
for n=1:n_tot
%n-th term of the series for f(x)=x
FSS_term_x(n,:)=((-2.*l.^2./n.pi).*cos(n.*pi)+2.*(l.^2)./(n.*pi).^2.*(cos(n.*pi)-1)).*sin(n.*pi.*x./l);
%-2.*l./(n.*pi).*cos(n.*pi).*sin(n.*x.*pi/l);
end
%Add up all the terms of the series
FS_y=sum(FSS_term_x,1);
%Plot the series
figure
plot(x,FS_y)
and here is the error message:
Dot indexing is not supported for variables of this type.
Error in untitled3 (line 16)
FSS_term_x(n,:)=((-2.*l.^2./n.pi).*cos(n.*pi)+2.*(l.^2)./(n.*pi).^2.*(cos(n.*pi)-1)).*sin(n.*pi.*x./l);
Does this error occur because the Fourier Sine Series I am trying to graph is piece-wise smooth?
Any feedback is appreciated!
Best,
RK