Borrar filtros
Borrar filtros

Execution of script as a function is not supported

48 visualizaciones (últimos 30 días)
Hector Meza
Hector Meza el 7 de Dic. de 2023
Respondida: Nipun el 18 de Dic. de 2023
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 comentarios
Walter Roberson
Walter Roberson el 7 de Dic. de 2023
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 el 8 de Dic. de 2023
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.

Iniciar sesión para comentar.

Respuestas (1)

Nipun
Nipun el 18 de Dic. de 2023
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

Categorías

Más información sobre Structural Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by