What is wrong with this MATLAB code ? Please fix it…. Im am trying to create a plot of two waves ref + source for all va

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

What is wrong with this MATLAB code ? Please fix it…. Im am trying to create a plot of two waves ref + source for all va

Post by answerhappygod »

What is wrong with this MATLAB code ? Please fix it…. Im am
trying to create a plot of two waves ref + source for all values of
x and t and show a standing wave with all values of t plotted on
one graph.
%% CODE for plotting Amplitude (y) versus Distance
(x)
% Defining all the parameters
f = 3e9; % f is the
frequency
spd = 2e8; % spd is the speed of
the wave
A = 1; % A is the
Peak Amplitude
lmd = (spd/f); % lmd is the lamda value
L = 2*lmd; % L is the
Transmission line Length
beta = 2*pi/lmd; % beta is the beta value
t = 0:0.125e-9:0.5e-9 %time range
meu = (2*pi*f); % meu is the freq in radian/sec
ph = 180; %reflection phase in
degrees
x = 0:0.0001:L; %defining the x axis
spacing up to L
source = A*sin(beta*x)-(meu*t); %
source wave
ref = A*sin(beta*(L-x)-meu*t-ph); % reflected
wave
plot(x,(ref+source)); %plot
the resultant wave
xlabel ('distance');
ylabel ('amplitude');
grid ('on');
title ('amplitude y versus distance x');
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply