필터 지우기
필터 지우기

Principal axis of moment of inertia-error in code

조회 수: 3 (최근 30일)
Mel A
Mel A 2022년 12월 7일
댓글: Samyuktha 2022년 12월 13일
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