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

Write a MATLAB Program to implement OR Gate, AND Gate and XOR Gate. Write a MATL

ID: 2319877 • Letter: W

Question

Write a MATLAB Program to implement OR Gate, AND Gate and XOR Gate. Write a MATLAB program to do the following: If input bit is 0: A sinusoidal signal with frequency f If input bit is 1: A sinusoidal signal with frequency f1 Amplitude Shift Keying (ASK): -change amplitude with each symbol - frequency constant -low bandwidth requirements -very susceptible to interference Frequency Shift Keying (FSK): -change frequency with each symbol -needs larger bandwidth Phase Shift Keying (PSK) -Change phase with each symbol -More complex -robust against interference

Explanation / Answer

(1)

clear all
close all
clc
% OR GATE
Y_OR=[or(0,0) or(0,1) or(1,0) or(1,1)]
% AND GATE
Y_AND=[and(0,0) and(0,1) and(1,0) and(1,1)]
% XOR GATE
Y_XOR=[xor(0,0) xor(0,1) or(1,0) xor(1,1)]

sample output


Y_OR =

0 1 1 1


Y_AND =

0 0 0 1


Y_XOR =

0 1 1 0

>>

(2)

clear all
close all
clc
f=100;
f1=1000;
t=0:0.1:10;
x=input('Enter input bit 0 or 1 :');
if x==0
Y=sin(2*pi*f*t);
plot(t,Y)
elseif x==1
Y=sin(2*pi*f1*t);
plot(t,Y)
else
disp('Invalid input')
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote