Reputation: 35
Title said it the most, but more specifically the question begin asked is...
"Your function should keep track of the number of times that it has been called
Your function will accept 1, 5 or 6 arguments and return 1, 2 or 3 values
All arguments must be either a scalar or a row matrix; you should check for this and print an error message and return with a 0 in the first return value if it is not true.
All arguments must be the same size: either they all must be scalars or they all must be row vectors of the same length. You must check for this and print an error message and return with a 0 in the first return value if it is not true"
Thats not the whole problem i assure you, but the part at which i struggle with the most. As in, i have no idea how to keep track of the number of times it's been called (with count maybe?) or have any idea how to check the argument whether or not this is a scalar or a row matrix. Also checking whether or not if they are the same size
I search up on how to do all this, no result. So therefore, i am going to assume this is not the basics.
Upvotes: 0
Views: 3309
Reputation: 33864
This is all basic stuff you just didn't search hard enough:
global variable
. Just increment it each time the function is entered. Alternitivly you can get a workspace variable with assignin
and eval
: HERE for Global. HERE for assignin. HERE for eval.nargin
which can be used to pass the inputs: HEREvarargout
: HEREsize
or length
to check the length of inputs. disp
to display a message, set the first output and use return
to return.Hope this helps.
Upvotes: 1