The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
****MATLAB QUESTION*****
Â
I need to complete the attached lab (Lab05-Audio_Filtering). I have attached the necessary .mat and .wav files described in the instructions. I have completed much of this lab, but I seem to have gotten stuck trying to convert the vector to a .wav file. I am also getting a couple of errors and I am not sure why. I have attached the work that I have done so far (lab5.m). Correct my .m file to show how this code should be written. Thank you.%% Lab 5
%% Clear command, variables
clear,clc,close all;
format short g
%% Load audio files
load filter_coeffs.mat;
[z,fs] = audioread('rdd.wav');
%% Create user inputs and if statements
channel_str = input('\n Choose which channel you would like to filter (1 for left, 2 for right)','s');
band_str = input('\n Choose which of 3 bands you would like in your filtered wav file','s');
include_str1 = input('\n Including band 1','s');
include_str2 = input('\n Including band 3','s');
%save_filter_str = input('\n Would you like to save your filtered results to a file (y/n)?','s');
%file_name_str = input('\n Enter the file name (do not include the .wav extension):','s')
% If left channel is chosen
if strcmp(channel_str,'1');
  Â
    left_chan = z(:,1);
end
  Â
% If right channel is chosen
if strcmp(channel_str,'2');
    right_chan = z(:,2);
end Â
%% Use filter to separate bands
desired_chan1 = left_chan
desired_chan2 = right_chan
% If band 1 is chosen
band1left = filter(lpf(2,:),lpf(1,:),desired_chan1);
band1right = filter(lpf(1,:),lpf(2,:),desired_chan2);
% If band 2 is chosen
band2left = filter(bpf(2,:),bpf(1,:),desired_chan1);
band2right = filter(bpf(1,:),bpf(2,:),desired_chan2);
% If band 3 is chosen
band3left = filter(hpf(2,:),hpf(1,:),desired_chan1);
band3right = filter(hpf(1,:),hpf(2,:),desired_chan2);
filtered = [band1left band1right band2left band2right band3left band3right];
%%%% Lab 5
%% Clear command, variables
clear,clc,close all;
format short g
%% Load audio files
load filter_coeffs.mat;
[z,fs] = audioread('rdd.wav');
%% Create user inputs and if statements
channel_str = input('\n Choose which channel you would like to filter (1 for left, 2 for right)','s');
band_str = input('\n Choose which of 3 bands you would like in your filtered wav file','s');
include_str1 = input('\n Including band 1','s');
include_str2 = input('\n Including band 3','s');
%save_filter_str = input('\n Would you like to save your filtered results to a file (y/n)?','s');
%file_name_str = input('\n Enter the file name (do not include the .wav extension):','s')
% If left channel is chosen
if strcmp(channel_str,'1');
  Â
    left_chan = z(:,1);
end
  Â
% If right channel is chosen
if strcmp(channel_str,'2');
    right_chan = z(:,2);
endÂ
%% Use filter to separate bands
desired_chan1 = left_chan
desired_chan2 = right_chan
% If band 1 is chosen
band1left = filter(lpf(2,:),lpf(1,:),desired_chan1);
band1right = filter(lpf(1,:),lpf(2,:),desired_chan2);
% If band 2 is chosen
band2left = filter(bpf(2,:),bpf(1,:),desired_chan1);
band2right = filter(bpf(1,:),bpf(2,:),desired_chan2);
% If band 3 is chosen
band3left = filter(hpf(2,:),hpf(1,:),desired_chan1);
band3right = filter(hpf(1,:),hpf(2,:),desired_chan2);
filtered = [band1left band1right band2left band2right band3left band3right];
%%
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly