Borrar filtros
Borrar filtros

exceeds matrix dimensions error. How to solve

1 visualización (últimos 30 días)
Alberto Gonzalo
Alberto Gonzalo el 4 de Nov. de 2016
Comentada: Alberto Gonzalo el 4 de Nov. de 2016
I am having a problem in my college project because although the matrix dados_voo is defined (184x4) the programme is giving me the index exceeds matrix dimensions in the variable Longitude. I don't know why this happens to Longitude and not to Latitude that comes before it. Would You kindly help me?
function [velrelsolo0,velrelsolof,Altmax,velvertmax,velvertmin,Distdirect]...
= OpcaoB(dados_voo)
if isempty(dados_voo) == 1
clc
disp('Deverá efectuar a opção A para prosseguir')
MyFlights
else
clc
%Variaveis
Latitude=dados_voo(:,1);
Longitude=dados_voo(:,2);
Altura=dados_voo(:,3);
Tempo=dados_voo(:,4);

Respuestas (2)

James Tursa
James Tursa el 4 de Nov. de 2016
Editada: James Tursa el 4 de Nov. de 2016
Enter this at the command line
dbstop if error
Then run your code. When the error is encountered, the program will pause at the offending line of code with all current workspace variables intact. Then do this:
size(dados_voo)
and start your debugging ...
  1 comentario
Alberto Gonzalo
Alberto Gonzalo el 4 de Nov. de 2016
Thank you, I know where the problem is now. It's loading dados_voo as a structure(1x1) an not as a matrix(184x4)

Iniciar sesión para comentar.


Nick Counts
Nick Counts el 4 de Nov. de 2016
Editada: Nick Counts el 4 de Nov. de 2016
Your code works as is for me. I ran this:
% Generate random 184x4 vector of data
dados_voo = randi(800, 184, 4);
if isempty(dados_voo) == 1
clc
disp('Deverá efectuar a opção A para prosseguir')
MyFlights
else
clc
%Variaveis
Latitude=dados_voo(:,1);
Longitude=dados_voo(:,2);
Altura=dados_voo(:,3);
Tempo=dados_voo(:,4);
end
Since I received no errors, and you pasted code from a function, my guess is you aren't passing the dados_voo argument/variable correctly.
Without seeing how you are calling your function, it's hard to say.
Hope this helps - good luck!

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by