Skip to content

Compatibility issue with MATLAB R2025b: "Colon operands must be real scalars" in PCRegionGrowing.m #120

@PatrikMrnka

Description

@PatrikMrnka

Hi Luca,
I'm testing STAPLE with the latest MATLAB R2025b and OpenSim 4.1. I encountered a runtime error during the femoral condyle extraction phase.

Error log:

Error using :
Colon operands must be real scalars.
Error in PCRegionGrowing (line 28)
Pts_Out(end+1:end+size(idx),:) =  Pts(idx,:);

Cause:
In newer MATLAB versions (R2023a+), the colon operator strictly requires scalars. size(idx) returns a 1x2 vector (e.g., [N, 1]), which triggers this error.

Suggested Fix:
Changing size(idx) to length(idx) or size(idx, 1) on line 28 of PCRegionGrowing.m resolves the issue:
Pts_Out(end+1:end+length(idx),:) = Pts(idx,:);

Verified: replacing size() with length() fixes the crash and allows the model generation to continue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions