I am trying to generate these 3 plots

1 view (last 30 days)
Mr.DDWW
Mr.DDWW on 3 Mar 2022
Answered: Walter Roberson on 3 Mar 2022
  5 Comments
Mr.DDWW
Mr.DDWW on 3 Mar 2022
clc;clear all;
n=100000;
alphat=1;
y_b=linspace(0,1);
% y_b=.1
for j=1:length(y_b)
sum_D=0;
for i=1:n
sum_D=sum_D+(((-1)^(i-1))/(((i-1)+0.5)*pi))*exp(-((i-1)+0.5)^2*pi^2*alphat)*cos((i-1)+0.5)*pi*y_b(j);
end
F(j)=2*sum_D;
end
plot(y_b,F);grid on;
I tried but not correct
Walter Roberson
Walter Roberson on 3 Mar 2022
Regardless of the theoretical shape, you can see from the below with very reduced n that after n = 2, the terms are too small to make any difference in the summation.
n=5.0000;
alphat=1;
y_b=linspace(0,1,10);
% y_b=.1
Pi = sym(pi);
for j=1:length(y_b)
sum_D = sym(zeros(1,n));
for i=1:n
sum_D(i)=(((-1)^(i-1))/(((i-1)+0.5)*Pi))*exp(-((i-1)+0.5)^2*Pi^2*alphat)*cos((i-1)+0.5)*Pi*y_b(j);
end
vpa(sum_D)
F(j)=2*sum(sum_D);
end
ans = 
ans = 
ans = 
ans = 
ans = 
ans = 
ans = 
ans = 
ans = 
ans = 
F(1:min(end,10)).'
ans = 
vpa(ans)
ans = 
plot(y_b,F);grid on;
simplify(F ./ F(2))
ans = 
vpa(ans)
ans = 

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 3 Mar 2022
sum_D(i)=(((-1)^(i-1))/(((i-1)+0.5)*Pi))*exp(-((i-1)+0.5)^2*Pi^2*alphat)*cos((i-1)+0.5)*Pi*y_b(j);
Look at that. How does the change of j affect it ?
j does not show up until y_b(j) which is a multiplier. And it is constant for all the different I values. So the result is going to be same as if you calculated for all the i values without including the y_b(j) term, and then multiplied by the y_b(j) term afterwards.
Which means that the result is going to be exactly the same each time, except multiplied by y_b(j) . And since the y_b is linear, that means you get a linear result.

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!