Principal axis of moment of inertia-error in code

3 次查看(过去 30 天)
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 个评论
Samyuktha
Samyuktha 2022-12-13
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by