Apply conditions in if statement.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
A = [];
for ii = 1:length(subSequence)
if any(ismember(subSequence{ii},out)) && mod(k-midpoint)<=G+l/2
A{end+1} = subSequence{ii};
end
end
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.
4 comentarios
Walter Roberson
el 13 de Oct. de 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
el 16 de Oct. de 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 :-
Respuestas (1)
Divyam
el 5 de Nov. de 2024 a las 10:16
Assuming that you are trying to find the modulus of the value so that you can effectively compare this with , the "mod" function is not fit for this use-case since it provides implementation for the modulo function instead of the modulus function.
To implement the modulus operation in your code, you can you the "abs" function instead of the "mod" function and the error thrown will be resolved.
A = [];
for ii = 1:length(subSequence)
% Replace mod with abs
if any(ismember(subSequence{ii},out)) && abs(k-midpoint)<=G+l/2
A{end+1} = subSequence{ii};
end
end
For more information regarding the "abs" function, refer to this documentation: https://www.mathworks.com/help/matlab/ref/double.abs.html
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!