フィルターのクリア

exceeds matrix dimensions error. How to solve

1 回表示 (過去 30 日間)
Alberto Gonzalo
Alberto Gonzalo 2016 年 11 月 4 日
コメント済み: Alberto Gonzalo 2016 年 11 月 4 日
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);

回答 (2 件)

James Tursa
James Tursa 2016 年 11 月 4 日
編集済み: James Tursa 2016 年 11 月 4 日
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 件のコメント
Alberto Gonzalo
Alberto Gonzalo 2016 年 11 月 4 日
Thank you, I know where the problem is now. It's loading dados_voo as a structure(1x1) an not as a matrix(184x4)

サインインしてコメントする。


Nick Counts
Nick Counts 2016 年 11 月 4 日
編集済み: Nick Counts 2016 年 11 月 4 日
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!

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by