Thread Subject:
Error - Index exceeds matrix dimensions..?

Subject: Error - Index exceeds matrix dimensions..?

From: John

Date: 6 Feb, 2007 05:33:28

Message: 1 of 8

Hi there, can anyone tell me what is wrong with my short piece of
code:

name = input('Please enter name of wav file to be processed
(noextension): ','s');
fname1 = [name '.wav'];
[y Fs] = wavread(fname1);
x = y([1:(30*Fs)]);
wavwrite(x,Fs,'excerpt2.wav')
Freq_Response = fft(x);
Magnitude = abs(Freq_Response);
Power = Freq_Response.*conj(Freq_Response);
Display_Freq = fftshift(Power);
Display_Freq2 = fftshift(Magnitude);
plot(Display_Freq2);

It returns the error message:

??? Error using ==> run
Index exceeds matrix dimensions.

I'm pretty sure it's something wrong with this line: x =
y([1:(30*Fs)]); ..But I really don't know what... Thanks for any
help!

Subject: Error - Index exceeds matrix dimensions..?

From: Michael Salloker

Date: 6 Feb, 2007 11:43:39

Message: 2 of 8

John schrieb:
> Hi there, can anyone tell me what is wrong with my short piece of
> code:
>
> name = input('Please enter name of wav file to be processed
> (noextension): ','s');
> fname1 = [name '.wav'];
> [y Fs] = wavread(fname1);
> x = y([1:(30*Fs)]);
> wavwrite(x,Fs,'excerpt2.wav')
> Freq_Response = fft(x);
> Magnitude = abs(Freq_Response);
> Power = Freq_Response.*conj(Freq_Response);
> Display_Freq = fftshift(Power);
> Display_Freq2 = fftshift(Magnitude);
> plot(Display_Freq2);
>
> It returns the error message:
>
> ??? Error using ==> run
> Index exceeds matrix dimensions.
>
> I'm pretty sure it's something wrong with this line: x =
> y([1:(30*Fs)]); ..But I really don't know what... Thanks for any
> help!

I suggest first to execute the expressions one by one, to be really
sure, which one causes the problem.

Michael

Subject: Error - Index exceeds matrix dimensions..?

From: Markus

Date: 6 Feb, 2007 05:51:34

Message: 3 of 8

Obviously there are no 30 seconds of sound saved in that file, i.e.
vector y is less than 30*Fs elements long.

Markus

Subject: Error - Index exceeds matrix dimensions..?

From: Anwesha

Date: 11 Dec, 2008 07:10:08

Message: 4 of 8

Markus <bhr3@gmx.de> wrote in message <ef4d07b.1@webcrossing.raydaftYaTP>...
> Obviously there are no 30 seconds of sound saved in that file, i.e.
> vector y is less than 30*Fs elements long.
>
> Markus
 hello all,
I had also received the same error in one of my programs. the code runs as follows:

function y=allow(p)
 
syms p
v=p(1:3);
t=p(4);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load actvar

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if t == 0
    U_1(1:8,1)=zeros(8,1);
    t_1=-T;
    tim(1)=0;
    count=1;
else
    load alloc
end
U_2=U_1;

%%%ASSIGNMENT OF VALUES%%%%
BB=G

ud = zeros(8,1);

Wu=(diag([1,1,1,1,25,25,25,25]))
Wv=diag([100,100,100])

umin_act=[ -5 -5 -5 -5 -8 -8 -8 -8]'; %%%value in degrees
umax_act=-umin_act;

ratelb=[-15 -15 -15 -15 -15 -15 -15 -15]'; %%%value in degrees/second
rateub=-ratelb; %%%value in degrees/second


    imax = 500; % Heuristic value
% [k,m] = size(B);
    tol = 1e-8;
    gam = 1e3;

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
if t_1+T-0.000001 <= t
   
    tic;

 umin=max(Ulower_act,U_1+ratelb*T)
 umax=min(Uupper_act,U_1+rateub*T)
 

    

   u=ip_alloc(BB,v,umin,umax,Wv,Wu,ud,gam,tol,imax)
                                    
    %%UPDATION%%
    U_1(1:8,1)=u;
% U_1(9,1)=gama;
    t_1=t_1+T;
    tim(count)=toc;
    count=count+1;
    
    
elseif t_1>t
    u=U_2(1:8);
else
    u=U_1(1:8);
end

y(1:8,1)=u

save alloc U_1 U_2 t_1 tim count



%%%ALLOCATION ALGORITHM

function [u] = ip_alloc(B,v,umin,umax,Wv,Wu,ud,gam,tol,imax)

.............................

%%%%%%%%%%%%%%%%%%

the program, when run, gives the error "index exceeds matrix dimensions" at the line
v=p(1:3); itself. can anyone help me to overcome this problem? this is an urgent requirement.

Anwesha

Subject: Error - Index exceeds matrix dimensions..?

From: Jos

Date: 11 Dec, 2008 07:22:05

Message: 5 of 8

"Anwesha " <majantali.sarkar@gmail.com> wrote in message <ghqecg$9mf$1@fred.mathworks.com>...
...
> hello all,
> I had also received the same error in one of my programs. the code runs as follows:
>
> function y=allow(p)
>
> syms p
> v=p(1:3);
...
> the program, when run, gives the error "index exceeds matrix dimensions" at the line
> v=p(1:3); itself. can anyone help me to overcome this problem? this is an urgent requirement.
>
Dear Anwesha,

Apparently, the variable p does not have enough elements, so extracting the first three of them fails. This could occur if you call the function with an improper argument like in
"allow(2)" or "allow([1 2])". So, check your call to this function.

hth
Jos

Subject: Error - Index exceeds matrix dimensions..?

From: Steven Lord

Date: 11 Dec, 2008 15:28:26

Message: 6 of 8


"Anwesha " <majantali.sarkar@gmail.com> wrote in message
news:ghqecg$9mf$1@fred.mathworks.com...
> Markus <bhr3@gmx.de> wrote in message
> <ef4d07b.1@webcrossing.raydaftYaTP>...
>> Obviously there are no 30 seconds of sound saved in that file, i.e.
>> vector y is less than 30*Fs elements long.
>>
>> Markus
> hello all,
> I had also received the same error in one of my programs. the code runs as
> follows:
>
> function y=allow(p)
>
> syms p

This line overwrites the input argument p with a 1-by-1 sym object p.
That's why the next line of your code fails.

If instead you want to convert your input argument p into a sym object, use:

p = sym(p);

> v=p(1:3);
> t=p(4);

*snip*

--
Steve Lord
slord@mathworks.com

Subject: Error - Index exceeds matrix dimensions..?

From: Hemanshi

Date: 22 Feb, 2011 17:58:06

Message: 7 of 8

I could not find any such parameter mismatch in my code but I am also getting the same error of "Index exceeding Matrix dimensions". Please help.

% --- Executes just before result is made visible.
function result_OpeningFcn(hObject, eventdata, handles, varargin)

% Choose default command line output for result
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

 set(handles.txt_1Name,'string',varargin(1));
 set(handles.txt_1Score,'string',varargin(2));
set(handles.txt_2Name,'string',varargin(3));
 set(handles.txt_2Score,'string',varargin(4));
set(handles.txt_3Name,'string',varargin(5));
 set(handles.txt_3Score,'string',varargin(6));

% --- Outputs from this function are returned to the command line.
function varargout = result_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;


% --- Executes on button press in bt_Ok.
function bt_Ok_Callback(hObject, eventdata, handles)
delete(gcf);

Subject: Error - Index exceeds matrix dimensions..?

From: Mohsin Tiwana

Date: 10 Jun, 2011 05:22:02

Message: 8 of 8

your .wav file which you take in "fname1 = [name '.wav'];" is too small. If you just take a bigger file (more samples), it would solve the problem



John <ruffryder6669990@aol.com> wrote in message <ef4d07b.-1@webcrossing.raydaftYaTP>...
> Hi there, can anyone tell me what is wrong with my short piece of
> code:
>
> name = input('Please enter name of wav file to be processed
> (noextension): ','s');
> fname1 = [name '.wav'];
> [y Fs] = wavread(fname1);
> x = y([1:(30*Fs)]);
> wavwrite(x,Fs,'excerpt2.wav')
> Freq_Response = fft(x);
> Magnitude = abs(Freq_Response);
> Power = Freq_Response.*conj(Freq_Response);
> Display_Freq = fftshift(Power);
> Display_Freq2 = fftshift(Magnitude);
> plot(Display_Freq2);
>
> It returns the error message:
>
> ??? Error using ==> run
> Index exceeds matrix dimensions.
>
> I'm pretty sure it's something wrong with this line: x =
> y([1:(30*Fs)]); ..But I really don't know what... Thanks for any
> help!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
index exceeds matr... Moon Datta 16 Aug, 2012 04:57:12
rssFeed for this Thread

Contact us