Source Code

Signals and communication Homework 2(8 problems)

Given the analog signal, sampled at the rate of 8000Hz (𝑑) = 3 π‘π‘œπ‘ ( 2πœ‹ Γ— 1500𝑑) + 2 π‘π‘œπ‘ ( 2πœ‹ Γ— 4200𝑑) t β‰₯ 0 Sketch the spectrum of the sampled signal up to 20 KHz Unsampled signal spectrum is; X(jw) —————————–(3/2)β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”- β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”1β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” -4.2 -1.5 1.5 4.2 kHZ Sampled signal spectrum is; X(jw) β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”(3/2)β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” —————————————————–1————————————————————– -17.5 -16.0 -14.5 -12.4 -11.8 -9.5 -6.5 -3.8 3.8 6.5 9.5 11.8 12.4 14.5 16.0 17 khz frequency In the above spectrum, there is an overlap. (b) Sketch the recovered analog signal spectrum if an ideal low pass filter with cutoff frequency of 4KHz is used to filter the sampled signal in order to recover the original signal. X(jw) khz frequency -3.8 +3.8 2. Assuming that a 5 bit ADC channel accepts analog input ranging from 0 to 4 volts , determine the following Number of quantization levels Levels=25=32 Quantization step size Step size Quantization output level when the analog signal is 1.2 volts =20th level Binary code produced by the ADC in this case (1.2 volts input). Binary code for decimal 20 is 10100 3. MATLAB Project: Given a signal waveform (𝑑) = 3.25 𝑠𝑖𝑛( 2πœ‹ Γ— 50𝑑) + 1.25 π‘π‘œπ‘ ( 2πœ‹ Γ— 100𝑑 + πœ‹/4) Sample it at 8000 samples per second and (a) Write a MATLAB program to quantize x(t) using 6 bit bipolar quantizer to obtain the Quantized signal xq, assuming the signal range is from -5 to 5. The function below performs signal quantization decoding. Here X-min will be -5 and X-max will be +5. The function is named decodingquant and is added to the path of the software. It will be called in the main program. The bits will be 6 bits since we are using a 6 bit bipolar quantizer. function deout = decodingquant(bits,Xmin,Xmax,I) le=2*bits; delta=(Xmax-Xmin)/le; deout=Xmin+I*delta; %the following function performs signal quantization decoding. This is a code for a function named quantization that performs signal quantization: function [I, out] = quantization(bits,Xmin,Xmax, value) le=2*bits; delta=(Xmax-Xmin)/le; I=round((value-Xmin)/delta); if I==le I=I-1; end if I<0 I=0; end out=Xmin+I*delta; The main program: This is where we will call our functions: quantization decodingquant We also initialize and write the code. This program quantizes the signal using 6-bits bipolar quantizer to obtain the to obtain the quantized signal x_qΒ and plots the original and quantized signal. clc clear close all Tm=1/50; %Time period of the signal fs=8000; %This is the samplig frequency T=1/fs; %The sampling time period t=0:T:2*Tm; %This the the two period-time array. signal=3.25*sin(2*pi*50*t)+1.25*co bits=6; %6 bit quantizer as asked in the question. l=length(signal); ter initializing everything, we carry out quantization Index=zeros; quadsignal=zeros; for x=1:l [Index(x), qout]=quantization(bits,-5,5,signal(x)); end % we call the function inprder to recover signal from quantized values. % also indicate the signal range:from -5 to 5. for x=1:l quadsignal(x)=decodingquant(bits,-5,5,Index(x)); end plot(t,signal,'b') hold on stairs(t,quadsignal,'r'); ylabel('Signal') % xlabel('time (s)') legend('Original ','Quantized ') %Inorder to plot original signal and quantised signal. hold off

TonyTour

package TonyTour; import java.text.DecimalFormat; import java.util.*; public class TonyTour { private static int participants; public static void main(String[] args) { // Declarations: int iChoice; Scanner cin = new Scanner(System.in); System.out.println(β€œTonyTour”); String name; String phone_number; System.out.print(” Please enter the name of the person making a booking: β€œ); name = cin.nextLine(); System.out.print(” What is the phone number for this person:”); phone_number = cin.nextLine(); System.out.print(” How many people will be participating in activities:”); participants = cin.nextInt(); System.out.print(β€œThankyou.”); System.out.println(); System.out.println(); // Instantiations: // Menu display System.out.println(β€œThe following are the activity options you can select to add to your booking:”); while(true) { System.out.println(β€œ1. Day trip to Philip Island Penguin Parade ($70 per person)”); System.out.println(β€œ2. Day trip to Werribee Open Plains Zoo ($39.85 per person)”); System.out.println(β€œ3. Day trip to Sovereign Hill in Ballarat ($65.50 per person)”); System.out.println(β€œ4. 2‐day trip to Buchan Caves in Gippsland ($140 per person)”); System.out.println(β€œ5. Western Victoria Great Ocean Rd 2‐day tour ($130.20 per person)”); System.out.println(β€œ0. Finished making selections”); // Prompt and get choice per instructions // Test the user’s choice (1-6 or bad data) System.out.print(β€œWhat would you like to add to the booking: β€œ); iChoice = cin.nextInt(); switch (iChoice) { case 1: fvCalcPhilip_sland(); break; case 2: fvCalcBuchan(); break; // Continue with menu; be sure to have an β€œelse” for out of range numbers case 3: fvCalcVictoria(); break; case 4: fvCalcWerribee(); break; case 5: fvCalcSovereign(); break; case 6: quit(); break; default: System.out.println(β€œError: Valid options are 1 to 6”); break; } } } // Method to calc and display Philip Island Penguin Parade: public static void fvCalcPhilip_sland() { double cost = 70; double credit_card_fee = 12; double total; double total_cost; total = cost * participants; total_cost = total + credit_card_fee; System.out.println(β€œBooked activities:”); System.out.println(β€œ1. Day trip to Philip Island Penguin Parade ($70 per person)- β€œ+ participants + ” people on 2/9/2022: ” + total ); System.out.println(β€œTotal cost (includes $12 credit card fee): ” +total_cost); } // Method to calc and display sphere: public static void fvCalcWerribee() { System.out.println(β€œ2. Day trip to Werribrr Open plains Zoo($39.85 per person)- β€œ+ participants + ” people on 2/9/2022: ” + total ); System.out.println(β€œTotal cost (includes $12 credit card fee): ” +total_cost); } } // Method to calc and display sphere: public static void fvCalcBuchan() { System.out.println(β€œ3. 2 day trip to Buchan Cves inb GIPPSLAND($140 per person)- β€œ+ participants + ” people on 2/9/2022: ” + total ); System.out.println(β€œTotal cost (includes $12 credit card fee): ” +total_cost); } } // Method to calc and display cylinder: public static void fvCalcVictoria() { System.out.println(β€œ4. Western victorial great Rd ($139.20 per person)- β€œ+ participants + ” people on 2/9/2022: ” + total ); System.out.println(β€œTotal cost (includes $12 credit card fee): ” +total_cost); } // Method to calc and display rectangular solid: public static void fvCalcSovereign() { System.out.println(β€œ5. day trip to sovereign hill in Ballarat ($65.50 per person)- β€œ+ participants + ” people on 2/9/2022: ” + total ); System.out.println(β€œTotal cost (includes $12 credit card fee): ” +total_cost); } // Method to exit: public static void quit() { System.out.println(β€œFinalising booking… β€œ); System.exit(0); return; } }

Support two (human) players on the same console (aka the CLI command line console). Player vs player. No computer. No need to implement single player mode.

Battleship Game Requirements: Support a menu. Play a new game. (Overwrite save file with default state/values). Load game. Quit. Support two (human) players on the same console (aka the cli command line console). Player vs player. No computer. No need to implement single player mode. No need to hide each players maps, print both players …

Support two (human) players on the same console (aka the CLI command line console). Player vs player. No computer. No need to implement single player mode. Read More Β»

CPSC165 – Introduction to Internet Concepts and Web Design principles

CPSC165 – Introduction to Internet Concepts and Web Design principles Spring 2020 Final Project: Build a moderate-size Web Site Submission due: Friday, June 26, 2020 (11:59pm) Β  Project Description Β  In this project you will build a moderate-size Web site. The theme of the Web site is decided by the members of your project group. …

CPSC165 – Introduction to Internet Concepts and Web Design principles Read More Β»

Forecasting Chicken Wing Demand

Exercise 1: Forecasting chicken wing demand The following data represents the weekly demand for chicken wings at a local restaurant during the past six weeks: Week 1 2 3 4 5 6 Demand 650 521 563 735 514 596 Complete the following: a.Β Β Β  Forecast the demand for week 7 using aΒ five-period Moving average. b.Β Β Β  Forecast …

Forecasting Chicken Wing Demand Read More Β»

Write a program that will open a data file (β€œdata.csv”) containing multiple rows and columns (no missing value)

COMP-5411 FA & FB Fall 2019 Assignment 1 This is NOT a group assignment Due Date: Wednesday, October 9, 11:59 pm Late submission is NOT allowed. 1) Write a program that will open a data file (β€œdata.csv”) containing multiple rows and columns (no missing value). Assume both your program and the data file are in …

Write a program that will open a data file (β€œdata.csv”) containing multiple rows and columns (no missing value) Read More Β»