0% found this document useful (0 votes)
44 views2 pages

Simulation Part Exp 1

The document describes using MATLAB code to simulate and plot sinusoidal waves. It shows how to create a single sinusoidal wave, add two waves together and plot the result, add more waves in a manual way, and then use a for loop to programmatically add many waves together and plot the cumulative wave.

Uploaded by

Mohamd barca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Simulation Part Exp 1

The document describes using MATLAB code to simulate and plot sinusoidal waves. It shows how to create a single sinusoidal wave, add two waves together and plot the result, add more waves in a manual way, and then use a for loop to programmatically add many waves together and plot the cumulative wave.

Uploaded by

Mohamd barca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Simulation part:

1. Creating sinusoidal wave using the following commands:


x=-pi:0.01:pi;
y=sin (x);
plot (y);

2. Adding two waves and plotting the results:


x=-pi:0.01:pi;
y1=sin (x);
y2=(1/3)*sin(3*x);
y=y1+y2;
plot (y);
3. Repeating step 2 and adding more waves:
x=-pi:0.01:pi;
y1=sin(x);
y2=(1/3)*sin(3*x);
y3=(1/5)*sin(5*x);
y4=(1/7)*sin(7*x);
y5=(1/9)*sin(9*x);
y=y1+y2+y3+y4+y5;
plot (y);

4. Using for loop to add more waves:


x=-pi:0.01:pi;
y=sin(x);
m=100;
for i=[Link]m
y=y+(1/i)*sin(i*x);
end
plot (y)

You might also like