Warning: Error updating FunctionLine in using fplot
Hi all, I wrote a function, using the PDE modeler app, that takes a radius as input and solves a PDE on a shape depending on r, and integrates the solution on the same shape. The function by itself seems to be working. However, when I try tu use fplot to plot it, it gives me the following warning: "Warning: Error updating FunctionLine. The following error was reported evaluating the function in FunctionLine update: Dimensions of arrays being concatenated are not consistent.", and I’m not really sure why that is. The code is below.
Thanks in advance!
fplot(@(r) Ttr(r), [1-1/sqrt(3), 0.47])
function [rt] = Ttr(r)
C1=[1; 1-r; 0; r; 0; 0; 0; 0];
P1=[2; 3; 0; (1-2*r)/(1-r); (1-2*r)/(1-r); 0; r/(1-r)*sqrt(1-2*r); -r/(1-r)*sqrt(1-2*r)];
dg=[C1, P1];
ns = char(‘C1′,’P1’);
ns = ns’;
sf=’C1+P1′;
[dl,bt] = decsg(dg,sf,ns);
[dl1,~] = csgdel(dl,bt);
%pdegplot(dl1,"EdgeLabels","on","FaceLabels","on")
%e=input("Inserire il numero di lati della figura: ");
model = createpde();
geometryFromEdges(model,dl1);
applyBoundaryCondition(model,"dirichlet","Edge", 1:6,"u",0);
specifyCoefficients(model,"m",0,"d",0,"c",1,"a",0,"f",1);
mesh=generateMesh(model, Hmax=0.05, Hmin=0.00005, GeometricOrder=’linear’);
[p,~,t] = meshToPet(mesh);
u=solvepde(model);
rt=0;
k=length(t(1,:));
for j=1:k
A=p(:,t(1,j));
B=p(:,t(2,j));
C=p(:,t(3,j));
M=[A(1),A(2),1; B(1),B(2),1; C(1),C(2),1];
rt=rt+1/2*(u.NodalSolution(t(1,j))+u.NodalSolution(t(2,j))+u.NodalSolution(t(3,j)))/3 * abs(det(M));
end
endHi all, I wrote a function, using the PDE modeler app, that takes a radius as input and solves a PDE on a shape depending on r, and integrates the solution on the same shape. The function by itself seems to be working. However, when I try tu use fplot to plot it, it gives me the following warning: "Warning: Error updating FunctionLine. The following error was reported evaluating the function in FunctionLine update: Dimensions of arrays being concatenated are not consistent.", and I’m not really sure why that is. The code is below.
Thanks in advance!
fplot(@(r) Ttr(r), [1-1/sqrt(3), 0.47])
function [rt] = Ttr(r)
C1=[1; 1-r; 0; r; 0; 0; 0; 0];
P1=[2; 3; 0; (1-2*r)/(1-r); (1-2*r)/(1-r); 0; r/(1-r)*sqrt(1-2*r); -r/(1-r)*sqrt(1-2*r)];
dg=[C1, P1];
ns = char(‘C1′,’P1’);
ns = ns’;
sf=’C1+P1′;
[dl,bt] = decsg(dg,sf,ns);
[dl1,~] = csgdel(dl,bt);
%pdegplot(dl1,"EdgeLabels","on","FaceLabels","on")
%e=input("Inserire il numero di lati della figura: ");
model = createpde();
geometryFromEdges(model,dl1);
applyBoundaryCondition(model,"dirichlet","Edge", 1:6,"u",0);
specifyCoefficients(model,"m",0,"d",0,"c",1,"a",0,"f",1);
mesh=generateMesh(model, Hmax=0.05, Hmin=0.00005, GeometricOrder=’linear’);
[p,~,t] = meshToPet(mesh);
u=solvepde(model);
rt=0;
k=length(t(1,:));
for j=1:k
A=p(:,t(1,j));
B=p(:,t(2,j));
C=p(:,t(3,j));
M=[A(1),A(2),1; B(1),B(2),1; C(1),C(2),1];
rt=rt+1/2*(u.NodalSolution(t(1,j))+u.NodalSolution(t(2,j))+u.NodalSolution(t(3,j)))/3 * abs(det(M));
end
end Hi all, I wrote a function, using the PDE modeler app, that takes a radius as input and solves a PDE on a shape depending on r, and integrates the solution on the same shape. The function by itself seems to be working. However, when I try tu use fplot to plot it, it gives me the following warning: "Warning: Error updating FunctionLine. The following error was reported evaluating the function in FunctionLine update: Dimensions of arrays being concatenated are not consistent.", and I’m not really sure why that is. The code is below.
Thanks in advance!
fplot(@(r) Ttr(r), [1-1/sqrt(3), 0.47])
function [rt] = Ttr(r)
C1=[1; 1-r; 0; r; 0; 0; 0; 0];
P1=[2; 3; 0; (1-2*r)/(1-r); (1-2*r)/(1-r); 0; r/(1-r)*sqrt(1-2*r); -r/(1-r)*sqrt(1-2*r)];
dg=[C1, P1];
ns = char(‘C1′,’P1’);
ns = ns’;
sf=’C1+P1′;
[dl,bt] = decsg(dg,sf,ns);
[dl1,~] = csgdel(dl,bt);
%pdegplot(dl1,"EdgeLabels","on","FaceLabels","on")
%e=input("Inserire il numero di lati della figura: ");
model = createpde();
geometryFromEdges(model,dl1);
applyBoundaryCondition(model,"dirichlet","Edge", 1:6,"u",0);
specifyCoefficients(model,"m",0,"d",0,"c",1,"a",0,"f",1);
mesh=generateMesh(model, Hmax=0.05, Hmin=0.00005, GeometricOrder=’linear’);
[p,~,t] = meshToPet(mesh);
u=solvepde(model);
rt=0;
k=length(t(1,:));
for j=1:k
A=p(:,t(1,j));
B=p(:,t(2,j));
C=p(:,t(3,j));
M=[A(1),A(2),1; B(1),B(2),1; C(1),C(2),1];
rt=rt+1/2*(u.NodalSolution(t(1,j))+u.NodalSolution(t(2,j))+u.NodalSolution(t(3,j)))/3 * abs(det(M));
end
end matlab, plot, error, function MATLAB Answers — New Questions