MATLAB Answers

Apply conditions in if statement.

7 views (last 30 days)
Silpa K
Silpa K on 13 Oct 2019
Commented: Shivam Prasad on 16 Oct 2019
A = [];
for ii = 1:length(subSequence)
if any(ismember(subSequence{ii},out)) && mod(k-midpoint)<=G+l/2
A{end+1} = subSequence{ii};
Iam getting errors when Iam using the second condition 'mod(k-midpoint)<=G+l/2'.
The error is like:
Error using mod
Not enough input arguments.
Error in Facetra (line 38)
if any(ismember(subSequence{ii},out)) && mod(k-midpoint)<=G+l/2
How can I avoid this errors.


Show 1 older comment
Silpa K
Silpa K on 13 Oct 2019
How can I apply this mod(k-midpoint)<=G+l/2 condition.
Walter Roberson
Walter Roberson on 13 Oct 2019
You appear to be wanting to use a different function named mod than the Mathworks function, which is the mathematical Modulo (remainder) operator. The mathematical Modulo operator always has two parameters: the value whose remainder is to be found, and the base with respect to which the remainder is to be found. For example, mod(7,3) asks to find the remainder with respect to division by 3 for the number 7.
You will need to locate source code or implementing library for whatever the function named mod does, and add that to your MATLAB path earlier than the MATLAB mathematics libraries.
If at all possible you should rename that third-party mod function, as otherwise it is very likely you will run into conflicts with the mathematical Modulo operator.
Shivam Prasad
Shivam Prasad on 16 Oct 2019
Hi Silpa,
Can you let me know what are you trying to do in these lines of code? Maybe you require a different function to implement the operation.
The mod function defined as mod(a,b) implements the mathematical operation a%b, which is the remainder when a is divided by b.
More on mod function :-

Sign in to comment.

Answers (0)

Translated by