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

Plot sine curve. Write a program, sinewave. m, that plots the function f(x) = Si

ID: 2080173 • Letter: P

Question

Plot sine curve. Write a program, sinewave. m, that plots the function f(x) = Sin (x/lambda) for x in the interval [-3p, 3p]. Use linspace to define a vector of x values and calculate f(x(k)) at each point x(k). Try various values of lambda > 0. Plotting damped motion Write a program, plotdamped.m, that plots the following function: f(x) = e^-x/a cos (2pi x/lambda) Choose an appropriate domain for the function and vary the parameters a and lambda (by changing the values set in the program and rerunning).

Explanation / Answer


%QUESTION a
clc;
close all;
clear all;

p = 10;
x = linspace(-3*p,3*p);

figure(1);

Lambda = 1;
fx = sin(x/Lambda);
subplot(3,1,1);
plot (x,fx);

Lambda = 2;
fx = sin(x/Lambda);
subplot(3,1,2);
plot (x,fx);

Lambda = 5;
fx = sin(x/Lambda);
subplot(3,1,3);
plot (x,fx);

%QUESTION b
clc;
close all;
clear all;

p = 10;
x = linspace(-3*p,0);

figure(1);

a = 1;
Lambda = 1;

fx = exp(-x./a).*cos(2*pi*(x/Lambda));
subplot(3,1,1);
plot (x,fx);

a = 0.5;
Lambda = 4;

fx = exp(-x./a).*cos(2*pi*(x/Lambda));
subplot(3,1,2);
plot (x,fx);

a = 4;
Lambda = 0.5;

fx = exp(-x./a).*cos(2*pi*(x/Lambda));
subplot(3,1,3);
plot (x,fx);