Not enough input arguments in Matlab R2021b

1 visualizzazione (ultimi 30 giorni)
function [K] = assembly_gl(Ke,gdl_bar,K)
%--Function that assembles the global stiffness matrix for the entire structure
%Ke=Enter the name of the finite element stiffness matrix you want to add
%gdl_bar=Vector containing the degrees of freedom of the finite element
%K=Specify the array in which the assembly will be stored
for igdl=1:4
ifila = gdl_bar(igdl);
for jgdl=1:4
jcolumna = gdl_bar(jgdl);
K(ifila,jcolumna) = K(ifila,jcolumna) + Ke(igdl,jgdl);
end
end
end
%I don't understand why the error comes out: Not enough input arguments.
%I have already entered all the arguments
%Please help me, thank you so much
  2 Commenti
Chunru
Chunru il 24 Lug 2022
The code above defined the function. How do you call it?
Pedro Rodriguez
Pedro Rodriguez il 24 Lug 2022
Modificato: Pedro Rodriguez il 24 Lug 2022
I saved the script as: untitled.m
Just in case, it is used to assemble, that is, join more than one matrix into a single matrix, so this code should be:
%DOFT=Degrees of freedom of the entire structure
%For example: DOFT=10
K = zeros(size(DOFT))
However I would use this code: K = zeros(size(DOFT)) in the script that executes the function:assembly_gl(Ke,gdl_bar,K)
My goal is to execute the function:assembly_gl(Ke,gdl_bar,K) many times with a for loop, however I just need the function to be able to execute:assembly_gl(Ke,gdl_bar,K) in a .m file
The problem is that I can't run: untitled.m, due to the error: Not enough input arguments, Error in untitled (line 7)

Accedi per commentare.

Risposta accettata

VBBV
VBBV il 24 Lug 2022
Ke = randi(4,4); % assume this as FE stiffness matrix to be added
gdl_bar = [2 2 4 4]; % no of DOF for each element in stiffness
K = zeros(size(Ke)); % pre-allocate matrix to store assembly
K = assembly_gl(Ke,gdl_bar,K) % resulting assembled matrix you want
K = 4×4
0 0 0 0 0 9 0 13 0 0 0 0 0 8 0 11
function [K] = assembly_gl(Ke,gdl_bar,K)
%--Function that assembles the global stiffness matrix for the entire structure
%Ke=Enter the name of the finite element stiffness matrix you want to add
%gdl_bar=Vector containing the degrees of freedom of the finite element
%K=Specify the array in which the assembly will be stored
for igdl=1:4
ifila = gdl_bar(igdl);
for jgdl=1:4
jcolumna = gdl_bar(jgdl);
K(ifila,jcolumna) = K(ifila,jcolumna) + Ke(igdl,jgdl);
end
end
end
give input matrix parameters to the function and pre-allocate any matrix used as argument in function
  3 Commenti
Torsten
Torsten il 24 Lug 2022
Modificato: Torsten il 24 Lug 2022
As you can see, the above code was run in MATLAB Online.
So it seems that something is not correct with your inputs to the function.
Pedro Rodriguez
Pedro Rodriguez il 24 Lug 2022
I have managed to clarify my doubts, thank you very much to VBBV

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by