필터 지우기
필터 지우기

Execution of script as a function is not supported

조회 수: 48 (최근 30일)
Hector Meza
Hector Meza 2023년 12월 7일
답변: Nipun 2023년 12월 18일
Im working on a problem for school and im trying to figure out a truss problem. I downloaded a function on mathworks TrussFEA. So when i excute the script i keep getting this problem " Execution of script TrussFEA as a function is not supported:" I don't know why, I am sure I am in the correct folder
I would be gratefull for your assistance, thank you
%Define the truss geometry and material properties
L_horizontal = 1;
L_vertical = 1;
L_inclined = sqrt(21);
E = 100e9; % Young's modulus in Pa
A = 1e-4; % Cross-sectional area in m^2
nu = 0.3; % Poisson's ratio
% Define the nodal coordinates and element connectivity matrix
nodes = [0, 0; L_horizontal, 0; 2*L_horizontal, 0; L_horizontal, L_vertical; L_horizontal, -L_vertical];
elements = [1, 2; 2, 3; 2, 4; 2, 5];
% Define the load cases
F_A = [0; 0; 10000; 0; 10000; 0; 10000; 0; 10000; 0; 10000; 0];
F_B = [0; 0; 0; 10000; 0; -10000; 0; 10000; 0; -10000; 0; 10000];
F_C = [0; 0; 10000; 0; 10000; 0; -10000; 0; 10000; 0; 10000; 0];
% Solve for the nodal displacements and element forces
[displacements_A, element_forces_A] = TrussFEA(nodes, elements, E, A, nu, F_A);
[displacements_B, element_forces_B] = TrussFEA(nodes, elements, E, A, nu, F_B);
[displacements_C, element_forces_C] = TrussFEA(nodes, elements, E, A, nu, F_C);
% Present the results in a table
results = table([displacements_A, element_forces_A], [displacements_B, element_forces_B], [displacements_C, element_forces_C], 'VariableNames', {'LoadCaseA', 'LoadCaseB', 'LoadCaseC'});
disp(results);
  댓글 수: 6
Walter Roberson
Walter Roberson 2023년 12월 7일
TrussFEA from the File Exchange https://www.mathworks.com/matlabcentral/fileexchange/86548-truss-finite-element-analysis-for-matlab is a function -- but it might not be the file being executed, or it might accidentally have been altered.
Stephen23
Stephen23 2023년 12월 8일
The function TRUSSFEA available here:
has the signature
function trussData = TrussFEA(trussData)
which anyway does not support the same number of input and output arguments as the OP shows.

댓글을 달려면 로그인하십시오.

답변 (1개)

Nipun
Nipun 2023년 12월 18일
Hi Hector,
I understand that you intend to execute the "TrussFEA" script with the mentioned parameters, but are getting an error based on function behaviour.
I assume that the TrussFEA script you are referring to is the same as here : https://in.mathworks.com/matlabcentral/fileexchange/86548-truss-finite-element-analysis-for-matlab
On reading the script, it is evident that the function signature is defined over one output and one input, as follows:
function trussData = TrussFEA(trussData)
However, based on your given code snippet, six arguments are passed to "TrussFEA" as opposed to supported one.
Additionally, the function signature expects a structure as input with the following properties:
%% Primary process
% extracting data from trussData
Nodes = trussData.node;
Elements = trussData.element;
Supports = trussData.support;
ExternalForces = trussData.force;
I would recommend altering your code to define a structure with mentioned properties. For instance, based on the provided information, you may do the following:
% Define the nodal coordinates and element connectivity matrix
nodes = [0, 0; L_horizontal, 0; 2*L_horizontal, 0; L_horizontal, L_vertical; L_horizontal, -L_vertical];
elements = [1, 2; 2, 3; 2, 4; 2, 5];
%% create a structure "trussData" with properties nodes and elements
trussData.node = nodes;
trussData.element = elements;
trussData.support = % Support variable here ;
trussData.force = % assign to external forces variable ;
%% execute the script
result = TrussFEA(trussData);
For additional information on expected argument's properties, refer to the "TrussFEA.m" file linked above. Hope this helps.
Regards,
Nipun

카테고리

Help CenterFile Exchange에서 Structural Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by