I have
function fps = ktsTOfps(kts)
%fps converts speed given in units of knots to speed in units of feet per
%second
% input variable: kts
% output variable: fps
% calling sequence: fps = ktsTOfps(kts)
% calculating fps
fps=kts*1.687809857;
kts=400;
fps = ktsTOfps(kts)
I keep getting the error "Index exceeds matrix dimensions." I don't really understand why this is popping up or where I need to go from here?

댓글 수: 2

Star Strider
Star Strider 2015년 11월 17일
One knot is 1.150779448023543 U.S. statute miles, or 6076.115485564304 U.S. feet, or more properly, 1.852 kilometers.
Rena Berman
Rena Berman 2017년 1월 12일
(Answers Dev) Restored question.

댓글을 달려면 로그인하십시오.

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 11월 17일

0 개 추천

Victoria - the error message is telling you that you are trying to access an element in an array (or matrix) using an index that exceeds the size of the array. As your function ktsTOfps doesn't do any indexing into an array, I wonder if the problem is when you call the function at
fps = ktsTOfps(its)
Could it be that you have created a local variable with the same name as ktsTOfps? In the Command Window type
which -all ktsTOfps
What do you see? You may observe something similar to
ktsTOfps is a variable.
/Users/geoffhayes/Documents/MATLAB/ktsTOfps.m % Shadowed
which would indicate that you do have a local variable (in the base workspace) that needs to be deleted.

댓글 수: 1

Victoria Billips
Victoria Billips 2015년 11월 17일
It was the last thing you stated. I finally noticed about 29 minutes after posting the question on here. I cleared my workspace and it worked perfectly. Thank you though!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

질문:

2015년 11월 17일

댓글:

2017년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by