Input a number in a function, what is the format of that number in the function?

조회 수: 1 (최근 30일)
EL
EL 2017년 3월 24일
댓글: Walter Roberson 2017년 3월 25일
I have done a function that accepts 1 input which is a number. What is the format of that number inside the function. The reason I ask is that I was trying to define a variable as follows
function pippo(len)
a = len +1;
which gives me the following error: "Index exceeds matrix dimensions."

답변 (1개)

Walter Roberson
Walter Roberson 2017년 3월 24일
I suspect that you accidentally assigned a value to a variable with the same name as your function, so you got a variable reference instead of a function reference. For example if you had
peppo = peppo(164)
then the first time peppo would refer to the function, but the result would be assigned to the variable peppo and then the next time peppo(164) would try to index position 164 of that variable.
  댓글 수: 4
EL
EL 2017년 3월 25일
I just simply import a .csv file on matlab that's call textdata. I then call the function
searchError(textdata, 15, 13, 2091)
which is supposed to scroll the file with a for cicle. For routine I believe you mean how I call the function? I'm sorry, not being English I may be mistaken.
Walter Roberson
Walter Roberson 2017년 3월 25일
Please post the complete routine, and an exact copy of the error message. Actually, please attach the file that has the code instead of just copy and paste it here.

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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by