Use MATLAB for answering the first two questions Attach and identify the code used for each part

Learning Goal: I’m working on a electrical engineering question and need the explanation and answer to help me learn.

function X = quantize( s, bit, rmode, lmode )

%QUANTIZE simulated fixed-point arithmetic

%——-

% Usage: X = quantize( S, BIT, RMODE, LMODE )

%

% returns the input signal S reduced to a word-length

% of BIT bits and limited to the range [-1,1). The type of

% word-length reduction and limitation may be chosen with

% RMODE: ’round’ rounding to nearest level

% ‘trunc’ 2’s complement truncation

% ‘magn’ magnitude truncation

% LMODE: ‘sat’ saturation limiter

% ‘overfl’ 2’s complement overflow

% ‘triang’ triangle limiter

% ‘none’ no limiter

if nargin ~= 4

vq = quantize(v,3,round,sat);

error(‘usage: quantize( S, BIT, RMODE, LMODE ).’);

end

if bit <= 0 || abs(rem(bit,1)) > eps

error(‘wordlength must be positive integer.’);

end

Plus1 = 2^(bit-1);

X = s * Plus1;

if strcmp(rmode, ’round’); X = round(X);

elseif strcmp(rmode, ‘trunc’); X = floor(X);

elseif strcmp(rmode, ‘ceil’); X = ceil(X);

elseif strcmp(rmode, ‘magn’); X = fix(X);

else error(‘unknown wordlength reduction spec.’);

end

if strcmp(lmode, ‘sat’)

X = min(Plus1 – 1,X);

X = max(-Plus1,X);

elseif strcmp(lmode, ‘overfl’)

X = X + Plus1 * ( 1 – 2*floor((min(min(X),0))/2/Plus1) );

X = rem(X,2*Plus1) – Plus1;

elseif strcmp(lmode, ‘triang’)

X = X + Plus1 * ( 1 – 2*floor((min(min(X),0))/2/Plus1) );

X = rem(X,4*Plus1) – Plus1;

f = find(X > Plus1);

X(f) = 2*Plus1 – X(f);

f = find(X == Plus1);

X(f) = X(f) – 1;

elseif strcmp(lmode, ‘none’) % limiter switched off

else error(‘unknown limiter spec.’);

end

X = X / Plus1;

Ace Your Assignments! 🏆 - Hire a Professional Essay Writer Now!

Why Choose Our Essay Writing Service?

  • ✅ Original writing: Our expert writers will write each paper from scratch, ensuring complete originality, zero plagiarism and AI free content.
  • ✅ Expert Writers: Our seasoned professionals are ready to deliver top-quality papers tailored to your needs.
  • ✅ Guaranteed Good Grades: Impress your professors with outstanding work.
  • ✅ Fast Turnaround: Need it urgently? We've got you covered!
  • ✅ 100% Confidentiality: Customer privacy is our number one priority. Your identity is anonymous to our writers.
🎓 Why wait? Let us help you succeed! Our Writers are waiting..

Get started

Starts at $9 /page

How our paper writing service works

It's very simple!

  • Fill out the order form

    Complete the order form by providing as much information as possible, and then click the submit button.

  • Choose writer

    Select your preferred writer for the project, or let us assign the best writer for you.

  • Add funds

    Allocate funds to your wallet. You can release these funds to the writer incrementally, after each section is completed and meets your expected quality.

  • Ready

    Download the finished work. Review the paper and request free edits if needed. Optionally, rate the writer and leave a review.