필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by