Question: Why is there this error in the code? Using MATLAB gn=3 sn=17 I =(gn*60)+(sn*2) A = 250/(I + 100) T = 1/(5*I) a0 =(A/2) number_of_points

Why is there this error in the code?

Using MATLAB

gn=3

sn=17

I =(gn*60)+(sn*2)

A = 250/(I + 100)

T = 1/(5*I)

a0 =(A/2)

number_of_points = 100

step_size = T/number_of_points

t = 0:step_size:T

f = a0

N=100

n=1:N

an = 0

bn = (A)/(n*pi)*(1 - cos(n*pi))

f = f + an*cos( n*pi*t/(T/2) ) + bn*sin( n*pi*t/(T/2) )

figure(1)

plot(t,f)

hold on

square_wave_f=A/2 + A/2*square(2*pi*t/T)

line_style ='r-'

plot(t,square_wave_f,line_style)

hold off

Step by Step Solution

3.41 Rating (138 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The error in the code is in the calculation of bn where the formula se... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!