Error using phase (line 16) Not enough input arguments.

10 vues (au cours des 30 derniers jours)
zaid mohd ghani
zaid mohd ghani le 29 Mai 2016
Commenté : zaid mohd ghani le 29 Mai 2016
someone can help to solve this particular error.. i have data time n voltage.. i want to use the threshold to select the peak value. i want transform the peak value into scatter graph in term of phase n charge.
  2 commentaires
Star Strider
Star Strider le 29 Mai 2016
You have a long list of undocumented code. Care to share with us in some detail what it does?
The data 'Book1 osi.xlsx' are also missing, so we can’t run your code.
zaid mohd ghani
zaid mohd ghani le 29 Mai 2016
sorry. this the file for that coding. please help me to solve this problem

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Mai 2016
You have
while aa<=newdatasize
and it is within that loop that phase gets assigned to as a variable. If that loop is never entered then phase will not be assigned to and the reference to phase in the later plot() call would be a reference to the function named phase, called without any arguments.
In the code before that line, you assign 1 to aa, so it has a definite value. newdatasize is assigned as data(:,2) minus 0. Unless the .xlsx happens to have only one numeric row, that means newdatasize would be a vector, so aa<=newdatasize would be comparing the scalar 1 to the vector newdatasize
When you have an if or while that is being applied to a logical vector, the condition is considered true only if all of the elements in the vector are considered true. So if there is any element, say index PQR, in newdatasize such that 1 <= newdatasize(PQR) is false, then the while would not be executed even once, leading to the situation described above where phase would not be assigned to and so would be a function call.
You could remove this behaviour of calling the function phase by making sure you assign something to the variable named phase . That would leave you with the task of figuring out what you really mean your code to do with comparing a vector to a scalar. You should probably read about any() and all()

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by