0

In audio recorder MATLAB 2014 edition function I have problem related to the size ?

I can't use waverecorder in the 2014 edition. I tried look for the answer but I didn't find.

Please tell me what changes should be made so they can be of same size

Error using  + 
Matrix dimensions must agree.

Error in FM (line 52)
fm1=cos( W1*t  +   f_dev1*a1 );  %The FM modulation
function fm1


Did you mean:
>> size(a1)

ans =

           1      352800

>> size(t)

ans =

           1     1411200



    % FM MO.mod&DE.mod code 
    fs=352800;
    x = 88200;                     % The sample frequency
    ts=1/fs;                        % time steps size
    t=0:ts:4-ts;                    % The time interval, it starts from zero
    No= length(t);                  % length of the time vector

    x1 = audiorecorder(x, 16, 1); 
    disp('Start speaking.') 
    recordblocking(x1, 4);
    disp('End of Recording.');   


    m1=getaudiodata(x1);              

    %The transpord to avoid mismatch size of vectors
    m1=m1'

    cutoff=4000;
    [a b]=butter(6,2*cutoff*ts);

    y1=filter(a,b,m1)  ;
    fc1=50000    ;         % carrier frequency for fm1&fm3
    f_dev1=(2./max(y1))*pi*8000       ; 

    W1=2*pi*fc1;                

    a1=(cumsum(y1).*ts); %here size of a1 352800


    fm1=cos( W1*t  +   f_dev1*a1 );  % here is the problem size t of 1411200
                                          wilea1 352800

the follwoing line will work with waverecorder

fs=352800;


x= 88200; %whatever sampling frequency your system supports


m1=wavrecord(4*x,x) % The length of this vector or speech signal will be 4x which will creat a lot of problems at the code.


m1=resample(m1,fs,x); % Now the length of the vector has been converted to No and everything will work.

can i use the same for audiorecorder ?

  • What is the expected size of each variable? – krisdestruction Apr 22 '15 at 02:50
  • I think because it FM modulation it should high that why i resample my voice to 352800 but you know that time gets multiplied by 4 ( 352800) i want both to be 352800 – user3136052 Apr 22 '15 at 02:59
  • possible duplicate of [Correlation between two signals with two different sizes](http://stackoverflow.com/questions/29759234/correlation-between-two-signals-with-two-different-sizes) – krisdestruction Apr 22 '15 at 03:05
  • Just use the code from the first part to that answer, but without the `corrcoeff` part – krisdestruction Apr 22 '15 at 03:06
  • I didn't get your point , what is corrcoeff please – user3136052 Apr 22 '15 at 03:10
  • ignore correcoeff. The `interp1` and `linspace` part is what you need to resample 1 variable into the length of another. At the end, `x` and `y` will have the same length, which is the exact question that you asked right? – krisdestruction Apr 22 '15 at 03:11
  • audiorecorder can't work with high frequency so I did use resample to make it from 88200 to 352800 and it worked but this create problem in the time vector it length now 1411200 . – user3136052 Apr 22 '15 at 03:17
  • Why not simply resample the time vector? What length do you expect for the time vector? – krisdestruction Apr 22 '15 at 03:19
  • a1=(cumsum(y1).*ts); in this line a1 has lenght of 352800 – user3136052 Apr 22 '15 at 03:19
  • fm1=cos( W1*t + f_dev1*a1 ); in this line a1 has lenght of 352800 while t is 1411200 – user3136052 Apr 22 '15 at 03:20
  • So you need all the lengths to be 352800? Again what's wrong with resampling `t`? – krisdestruction Apr 22 '15 at 03:22
  • all what i want is to be the same in length so that the question work : – user3136052 Apr 22 '15 at 03:22
  • I want that too, but you're not answering all of my questions or the question has too many details that doesn't represent the minimal reproducible code. – krisdestruction Apr 22 '15 at 03:22
  • can I resample from high to low. i will try it now – user3136052 Apr 22 '15 at 03:23
  • well I assume you need `t` to be a length of 352800, shouldn't you be sampling `t` to be higher or is my assumption about the expected length of `t` wrong? – krisdestruction Apr 22 '15 at 03:24
  • the length of time vector is 1411200 while a1 352800 I have to reduce the length of t – user3136052 Apr 22 '15 at 03:26
  • oh yes sorry you're correct, I divided the wrong way. Let me know what the results are! – krisdestruction Apr 22 '15 at 03:29
  • i didn't work , give me some error about the memory (out of memory – user3136052 Apr 22 '15 at 04:15
  • can I get benefit from knowing that will e multiplied by 4 like if use the folowing line it will work fs=352800; x= 88200; %whatever sampling frequency your system supports m1=wavrecord(4*x,x) % The length of this vector or speech signal will be 4x which will creat a lot of problems at the code. m1=resample(m1,fs,x); % Now the length of the vector has been converted to No and everything will work. – user3136052 Apr 22 '15 at 04:18
  • I added the line in the code above ?! – user3136052 Apr 22 '15 at 04:20
  • I'll be quite frank. I can't easily reproduce the issue you're getting. Not only do I not have the data, the code is extensively long. Can you reformat your whole question as follows: minimize your code to say 20 lines max that executes up to the error, show the full error you're getting, some dummy/real data before the snippet, what is expected variable length, and what is the actual variable length? – krisdestruction Apr 22 '15 at 04:51
  • I minimize the code . I went t and a1 have the same length – user3136052 Apr 22 '15 at 05:19
  • `waverecord` has been removed in 2015a, someone else probably has to help you out since I can't access the function. – krisdestruction Apr 22 '15 at 07:34

0 Answers0