From: dpb on
kk KKsingh wrote:
....
> I have written some thing look like above ! But not good and index2 is
> giving me error ! also i want s2 and t2 to be saved in matrix form so
> that i can check them whenever i wan
>
> close all;
> % Testing the AUdio data set load Audio.mat % Loading the Audio DATA
>
> %Assigning the variables
> s=A_0;
> % Making the time axis !
> t0=0:dt:dt*(750-1);
> t1=t0';
> [r,c]=size(s);
> t2=repmat(t1,1,315); % creating copies of the time axis
> s2=zeros(size(s));
> lim=32767
>
> for idx=1:c
> s2(:,idx)=s(:,idx);
> t2(:,idx)=t1;
> index1 = find(s2(:,idx)==32767)
> s2(index1)=[];
> t2(index1)=[];
> index2 = find( s2(:,idx)==-32767)
> s2(index2) = [];
> t2(index2)=[];
> end

That has the problem I already described -- you are trying to create a
square matrix w/ a variable number of rows/column. You _CAN'T_ do
that!!! BTW, when you do the [] operation on the arrays, w/ the index
vectors returned from find() as you have you'll have turned the array
that started initially by the zeros() call as 2D matrix into a 1D
vector. After that, your logic breaks entirely.

It's why I suggested either one of two alternatives -- deal w/ the
column and process it while/after the elimination of the clipped values
or if you must have all data in memory simultaneously (and I've seen
nothing posted so far that shows any reason why must be so) then you'll
need to store each column in a cell array.

Read the "Getting Started" section on cell arrays for further details.

--
From: dpb on
dpb wrote:
....

> It's why I suggested either one of two alternatives -- deal w/ the
> column and process it while/after the elimination of the clipped values
> or if you must have all data in memory simultaneously (and I've seen
> nothing posted so far that shows any reason why must be so) then you'll
> need to store each column in a cell array.
....

One last aside...

Or, the third possibility also previously mentioned if you are
extrapolating to fill in missing data (altho on reflection if that's so
I suppose you wouldn't be decimating the time vector concomitantly) you
could in that case keep the 2D array arrangement but would have to fill
in the missing values first to keep the length consistent.

--