Azzera filtri
Azzera filtri

exceeds matrix dimensions error. How to solve

1 visualizzazione (ultimi 30 giorni)
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);

Risposte (2)

James Tursa
James Tursa il 4 Nov 2016
Modificato: James Tursa il 4 Nov 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 Commento
Alberto Gonzalo
Alberto Gonzalo il 4 Nov 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)

Accedi per commentare.


Nick Counts
Nick Counts il 4 Nov 2016
Modificato: Nick Counts il 4 Nov 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!

Community Treasure Hunt

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

Start Hunting!

Translated by