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

Can any one please help with the matlab code? I want the output is delta_t and p

ID: 3758003 • Letter: C

Question

Can any one please help with the matlab code? I want the output is delta_t and plot angles vs. delta_t but it keeps getting errors below:

Error using plot
Invalid first data argument

Error in audio2>audio_file
plot(Angles, delta_t)

Error in audio2
audio_file(Left_ear{index},fs);

* Here is my code:

Left_ear = {p90L p80L p70L p60L p50L p45L p40L p30L p20L p15L p10L p5L c0L n5L n10L n15L n20L n30L n40L n45L n50L n60L n70La n80L n90L};

Right_ear = {p90R p80R p70R p60R p50R p45R p40R p30R p20R p15R p10R p5R c0R n5R n10R n15R n20R n30R n40R n45R n50R n60R n70Ra n80R n90R};

for index=1: length(Left_ear)

audio_file(Left_ear{index},fs);

end

for index=1:length(Right_ear)

audio_file(Right_ear{index});

end  

function [delta_t] = audio_file(file,fs)

for m=1:1:length(file)

  N=length(file);   

t=(1:N)/fs;

  a=t';

  b=file(1:N);

  C=horzcat(a,b);

   for array=1:1:length(a)/2

if C(array,2)>0.5

   t1_value=C(array,1);

   t1_left=array;

break

end

  end

for array=1:1:length(a)

array= t1_left+12000;

if C(array,2)>0.4

t2_value=C(array,1);

break

   end

end

delta_t= t2_value -t1_value;

   Angles={90 80 70 60 50 45 40 30 20 15 10 5 0 -5 -10 -15 -20 -30 -40 -45 -50 -60 -70 -80 -90};

   plot(Angles, delta_t)

end

  

  

  

  

  

Explanation / Answer

Error with Audio files with MATLAB code.

The syntax for audioread files is

[y,Fs] = audioread(filename)
[y,Fs] = audioread(filename,samples)
[y,Fs] = audioread(___,dataType)

Simple example for audioread file

Step1 :Creare a WAVE file in that current folder

filename='hi.wav';
audiowrite(filename,y, Fs)
clear y Fs


Step 2: Read the data using audioread
[y, Fs]=audioread('hi.wav');


Step3:play that audio

sound(y, Fs)


function for audio2 using MATLAB

function [ ] = audio2( )

%Positive 90 Degree Files
[p90L, Fs] = audioread('p90L1.wav');
[p90R, Fs] = audioread('p90R2.wav');

%Positive 70 Degree Files
[p70L, Fs] = audioread('p70L3.wav');
[p70R, Fs] = audioread('p70R4.wav');

%Positive 80 Degree Files
[p80L, Fs] = audioread('p80L5.wav');
[p80R, Fs] = audioread('p80R6.wav');

%Positive 60 Degree Files
[p60L, Fs] = audioread('p60L7.wav');
[p60R, Fs] = audioread('p60R8.wav');

%Positive 50 Degree Files
[p50L, Fs] = audioread('p50L9.wav');
[p50R, Fs] = audioread('p50R10.wav');


%Positive 40 Degree Files
[p40L, Fs] = audioread('p40L11.wav');
[p40R, Fs] = audioread('p40R12.wav');

%Positive 45 Degree Files
[p45L, Fs] = audioread('p45L13.wav');
[p45R, Fs] = audioread('p45R14.wav');


%Positive 30 Degree Files
[p30L, Fs] = audioread('p30L15.wav');
[p30R, Fs] = audioread('p30R16.wav');

%Positive 20 Degree Files
[p20L, Fs] = audioread('p20L17.wav');
[p20R, Fs] = audioread('p20R18.wav');

%Positive 15 Degree Files
[p15L, Fs] = audioread('p10L19.wav');
[p15R, Fs] = audioread('p10R20.wav');

%Positive 10 Degree Files
[p10L, Fs] = audioread('p10L21.wav');
[p10R, Fs] = audioread('p10R22.wav');

%Positive 5 Degree Files
[p5L, Fs] = audioread('p5L23.wav');
[p5R, Fs] = audioread('p5R24.wav');

%Center Files
[c0L , Fs] = audioread('c0L25.wav');
[c0R , Fs] = audioread('c0R26.wav');

%Negative 5 Degree Files
[n5L, Fs] = audioread('n5L27.wav');
[n5R, Fs] = audioread('n5R28.wav');

%Negative 10 Degree Files
[n10L, Fs] = audioread('n10L29.wav');
[n10R, Fs] = audioread('n10R30.wav');

%Negative 20 Degree Files
[n20L, Fs] = audioread('n20L31.wav');
[n20R, Fs] = audioread('n20R32.wav');

%Negative 15 Degree Files
[n15L, Fs] = audioread('n15L33.wav');
[n15R, Fs] = audioread('n15R34.wav');

%Negative 30 Degree Files
[n30L, Fs] = audioread('n30L35.wav');
[n30R, Fs] = audioread('n30R36.wav');

%Negative 45 Degree Files
[n45L, Fs] = audioread('n45L37.wav');
[n45R, Fs] = audioread('n45R38.wav');

%Negative 40 Degree Files
[n40L, Fs] = audioread('n40L39.wav');
[n40R, Fs] = audioread('n40R40.wav');

%Negative 60 Degree Files
[n60L, Fs] = audioread('n60L41.wav');
[n60R, Fs] = audioread('n60R42.wav');

%Negative 50 Degree Files
[n50L, Fs] = audioread('n50L43.wav');
[n50R, Fs] = audioread('n50R44.wav');

%Negative 70 Degree Files
[n70La, Fs] = audioread('n70a_01.wav');
[n70Ra, Fs] = audioread('n70a_02.wav');

%Negative 80 Degree Files
[n80L, Fs] = audioread('n80L34wav');
[n80R, Fs] = audioread('n80R35.wav');

%Negative 90 Degree Files
[n90L, Fs] = audioread('n90_01.wav');
[n90R, Fs] = audioread('n90_02.wav');

If an error like "undefined function or undefined method for the input argument type of 'char' ".
in Matlab package dont have audioread function .
For checking purpose type as
help audioread
and get audioread not found means missed that function in that package.


If error like "Too many arguments
Some MP3 audio files it is not support the old version.New version have all packages with function