Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(MATLAB)I have question about finding the (rmse)Root-mean-square deviation value

ID: 3759829 • Letter: #

Question

(MATLAB)I have question about finding the (rmse)Root-mean-square deviation value in this code. could you please help me how to find it for all value on n=(2,10,20,50,100) at the same graph and show me how does the graph look like ..Thank you

clc

clear all

close all

syms t k L n

evalin (symengine, 'k,type::integer');

a= @(f,t,k,L) int(f*cos(k*pi*t/L)/L,t,-L,L);

b=@(f,t,k,L) int(f*sin(k*pi*t/L)/L,t,-L,L);

fs=@(f,t,n,L) a(f,t,0,L)/2+symsum (a(f,t,k,L)*cos(k*pi*t/L)+b(f,t,k,L)*sin(k*pi*t/L),k,1,n);

f=heaviside(t);

g=inline(vectorize(fs(f,t,2,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,1),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=2')

g=inline(vectorize(fs(f,t,2,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,1),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=2')

g=inline(vectorize(fs(f,t,10,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,2),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=10')

g=inline(vectorize(fs(f,t,20,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,3),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=20')

g=inline(vectorize(fs(f,t,50,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,4),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=50')

g=inline(vectorize(fs(f,t,100,1)));

h=inline(vectorize(f));

X=-1:.001:1;

subplot(3,2,5),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');

hold on

plot(X,h(X))

hold off

title('partial sum with n=100')

Explanation / Answer

syms t k L n
evalin (symengine, 'k,type::integer');
a= @(f,t,k,L) int(f*cos(k*pi*t/L)/L,t,-L,L);
b=@(f,t,k,L) int(f*sin(k*pi*t/L)/L,t,-L,L);
fs=@(f,t,n,L) a(f,t,0,L)/2+symsum (a(f,t,k,L)*cos(k*pi*t/L)+b(f,t,k,L)*sin(k*pi*t/L),k,1,n);
f=heaviside(t);

g=inline(vectorize(fs(f,t,2,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,1),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=2')
g=inline(vectorize(fs(f,t,2,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,1),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=2')


g=inline(vectorize(fs(f,t,10,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,2),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=10')


g=inline(vectorize(fs(f,t,20,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,3),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=20')


g=inline(vectorize(fs(f,t,50,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,4),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=50')
g=inline(vectorize(fs(f,t,100,1)));
h=inline(vectorize(f));
X=-1:.001:1;
subplot(3,2,5),plot(X,g(X),'r'),xlabel('Time(s)'),ylabel('Amplitude'),title('Time Shifting');
hold on
plot(X,h(X))
hold off
title('partial sum with n=100')