App Designer and external function
12 views (last 30 days)
Show older comments
Im having issues with running my app. The m file alone works but, when I attempt to convert it to the app, its throwing errors just in the app. My code involves matrixes and vectors. Error is at the external function ElementofFasteners, I have commented the lines for a visual representation of what I am seeing. Like I said, this works as a standalone m. file without the app. What am I missing and are the app.inputs creating different variables or... need a bit of help
Error using /
Matrix dimensions must agree.
Error in Fasteners (line 29)
c1=(((t1 + t2)/(2*D))^a);
% Button pushed function: SolveButton
function SolveButtonPushed(app, event)
%Solve Everything here
app.FastF1.Value = numfast(app.nf); % numfast external function-works
app.FastF2.Value = app.E1;
app.FastF3.Value = app.d3;
app.nnel = 3 * app.nf;
app.nnode = 2 + (2 * app.nf);
app.sdof = app.nnode * app.ndof;
kk=zeros(app.sdof,app.sdof);
index=zeros(app.nel*app.ndof,1); %orange underline (use Plate(app.,..
for iel=1:app.nnel
if iel <= (app.nnel - app.nf)
[k]=Plate(app.E1,app.w,app.t1,app.L); % Plate external function-orange underline (use Plate(app.,..
index = ElementdofPlate(iel,app.nel,app.ndof,app.nf);
else
if app.count == 1
d = app.d2;
app.count = app.count + 1;
elseif app.count == 2
d = app.d3;
app.count = app.count + 1;
elseif app.count == 3
d = app.d4;
app.count = app.count + 1;
elseif app.count == 3
d = app.d5;
app.count = app.count + 1;
elseif app.count == 4
d = app.d6;
app.count = app.count + 1;
else
d = app.d1;
app.count = app.count + 1;
end
[k]=Fasteners(app.E1,app.E2,app.E3,app.t1,app.t2,d); % Fastners external function-orange underline (use Fasteners(app.,..
index = ElementdofFasteners(iel,app.nf); % external function-orange underline (use Elemt..(app.,..
end
kk=Assemble(kk,k,index); % external function-orange underline (use Elemt..(app.,..
end
%
% Applying the Boundary conditions
[kk] = constraints(kk,1) ;% external function-orange underline (use Elemt..(app.,..
[kk] = KRED(kk,app.nnode);% external function-orange underline (use Elemt..(app.,..
[uu] = Displacements(kk,app.P,app.nnode); % external function-orange underline (use Elemt..(app.,..
app.FastF4.Value = uu(1);
0 Comments
Accepted Answer
More Answers (1)
Cris LaPierre
on 8 Jun 2020
Edited: Cris LaPierre
on 8 Jun 2020
You do not call a function named ElementofFasteners in the code you have shared.
The error message suggests to me the problem is that your inputs in the app are different from what they are when you call the function in MATLAB. Since we have no information on what they should be, I'd suggest starting to debug by using breakpoints and comparing the inputs in the app to what you expect them to be.
I'd suggest paying close attention to the dimensions. It might be that the function was designed for the inputs to be column vectors, but in the app they are created as a row vectors.
3 Comments
Cris LaPierre
on 8 Jun 2020
Ah, sorry. I searched for it but it obviously didn't find this.
iel is an integer, but I don't know what app.nf is.
What is the calling syntax of ElementdofFasteners? Can you share the function declaration line? Do you perhaps need to pass the inputs in as a 1x2 vector? If so, enclose the inputs in square brackets.
index = ElementdofFasteners([iel,app.nf]);
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!