Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Assuming that srcHoughMatrix is a 3-dimensional matrix :

Instead of

    if (currentRadius >= MINIMUM_ALLOWED_RADIUS )
    % we're using only radiuses that are 6 or above 
        currentHough = srcHoughMatrix(index,jindex,currentRadius);
        srcHoughMatrix(index,jindex,currentRadius) = currentHough + 1;
    end

How can I add 1 to each cell if the condition is true , without using a temporary variable or without

srcHoughMatrix(index,jindex,currentRadius)  = srcHoughMatrix(index,jindex,currentRadius)  + 1;

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
465 views
Welcome To Ask or Share your Answers For Others

1 Answer

Not that I wouldn't do what @Jonas suggested, but what about using operator ? it is used to define new user-defined operator symbols or to delete them (you will need the symbolic toolbox though).

operator(symb, f, T, prio) defines a new operator symbol symb of type T (Prefix | Postfix | Binary | Nary) with priority prio. The function f evaluates expressions using the new operator.

Given the operator symbol "++", say, with evaluating function f, the following expressions are built by the parser, depending on the type of the operator, where :

Prefix: The input ++x results in f(x).

Postfix: The input x++ results in f(x).

Binary: The input x ++ y ++ z results in f(f(x, y), z).

Nary: The input x ++ y ++ z results in f(x, y, z)).

see more at matlab's documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...