Principal axis of moment of inertia-error in code

1 view (last 30 days)
I am calculating the pricipal axis using moment of inertia.
In the code I use (Not written by me, I am a beginner) I get following error. Only the first part attached.
Thanks very much
Operator '+' is not supported for operands of type 'struct'.
Error in mass (line 15)
connection = connection + (1);
function [Centroid,SurfaceArea,Volume,CoM_ev123,CoM_eigenvectors,I1,I2,I_CoM,I_origin,patches] = mass(varargin)
if (nargin == 0)
[ivFile,filepath] = uigetfile('*.stl','SELECT FILE');
varargin{1} = fullfile(filepath, ivFile);
end
if (nargin==2 && ischar(varargin{1}) && ischar(varargin{2}))
varargin{1} = fullfile(varargin{1},varargin{2});
end
if (ischar(varargin{1}))
[points, connection] = read_vrml(varargin{1});
connection(:,1) = [];
connection = connection + 1;
elseif (nargin==2 && isnumeric(varargin{1}) && isnumeric(varargin{2}) && size(varargin{1},2)==3 && size(varargin{2},2)>=3)
points = varargin{1};
connection = varargin{2};
if (size(connection,2)==4)
connection(:,4)= [];
end
if (min(min(connection))==0)
warning('MassProperties:ConnIndex','Connection matrix appears to be still 0-indexed, adding 1 to all indices');
connection = connection + 1;
end
else
error('MassProperties:Arugments', 'No ivFile or pts & conn were passed in');
end
  1 Comment
Samyuktha
Samyuktha on 13 Dec 2022
Hi Mel,
You're getting the following error as 'read_vrml' reads a VRML 1.0 file into a MATLAB structure and hence, connection is of the datatype 'struct'.
More details about 'read_vrml' can be found in the documentation link : read_vrml

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!