Plot sin wave with changing amplitude
Show older comments
Hi,
I plot Bx and By but I want to changing amplitude as the follwing
B0 = 0.45;
wav = 0.0223;
z1= 1.75
err= 10
z = linspace(0,z1,10000);
segb = B0/err;
seglam = wav/err;
Bx = (B0+segb).*sin((2 * pi * z) / (wav+seglam));
By = (B0+segb).*cos((2 * pi * z) / (wav+seglam));
plot(z,Bx,z,By)
title('Introduce errors')
it work for fixed err but it is suppose that Bx changing in z direction with error +-10 %
The output from this code as

The true output should be

How I can do that
5 Comments
Voss
on 26 Dec 2021
Are there supposed to be random fluctuations in the amplitude of Bx and By?
Image Analyst
on 26 Dec 2021
What function defines the amplitude? You need to do something like
amplitude = whatever, some vector as long as Bx and By
% Create amplitude modulated signal
signal = amplitude .* Bx; % Make sure you use dot star and not just star.
DGM
on 27 Dec 2021
In case it's still not clear, you're getting exactly what you've written. You've asserted that the error is a constant value.
err= 10 % this is a constant
segb = B0/err; % this is a constant too
seglam = wav/err; % so is this
Bx = (B0+segb).*sin((2 * pi * z) / (wav+seglam));
The output amplitude is B0+segb, which is the same as saying 1.1*B0. The amplitude never changes because 1.1 never changes.
As an aside, I have to question whether the error is supposed to simultaneously influence both amplitude and frequency, or whether that's supposed to be two separate error sources.
Ali Gamal
on 28 Dec 2021
Ali Gamal
on 28 Dec 2021
Accepted Answer
More Answers (0)
Categories
Find more on Map Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



