Tag Archives: matlab
1-Way Repeated ANOVA
Hello, I want to do a repeated 1-way anova on the data below. I am really struggling to do it matlab, and I could use help. I want to compare visual and haptic conditions to control. (I’m new to matlab)
subj visual haptic control
____ _______ _______ ________
2 1.0213 0.60644 -0.41386
3 0.32353 0.28596 0.48249
4 0.5959 1.024 0.24434
6 0.83399 0.84673 0.54047
7 2.2764 1.4464 2.5757
9 0.99934 2.5184 0.85768
11 1.9565 3.0488 1.3296
12 0.93319 1.3867 1.0831
I was thinking I would rm anova?Hello, I want to do a repeated 1-way anova on the data below. I am really struggling to do it matlab, and I could use help. I want to compare visual and haptic conditions to control. (I’m new to matlab)
subj visual haptic control
____ _______ _______ ________
2 1.0213 0.60644 -0.41386
3 0.32353 0.28596 0.48249
4 0.5959 1.024 0.24434
6 0.83399 0.84673 0.54047
7 2.2764 1.4464 2.5757
9 0.99934 2.5184 0.85768
11 1.9565 3.0488 1.3296
12 0.93319 1.3867 1.0831
I was thinking I would rm anova? Hello, I want to do a repeated 1-way anova on the data below. I am really struggling to do it matlab, and I could use help. I want to compare visual and haptic conditions to control. (I’m new to matlab)
subj visual haptic control
____ _______ _______ ________
2 1.0213 0.60644 -0.41386
3 0.32353 0.28596 0.48249
4 0.5959 1.024 0.24434
6 0.83399 0.84673 0.54047
7 2.2764 1.4464 2.5757
9 0.99934 2.5184 0.85768
11 1.9565 3.0488 1.3296
12 0.93319 1.3867 1.0831
I was thinking I would rm anova? anova, ranova, statistics, table, simple MATLAB Answers — New Questions
matlab compiler vs mcc functionality
Hi, I am testing out the matlab compiler and the mcc function. I cannot get a full overlap of functionality between them. For example:
When using the mcc function, is there a way to include matlab runtime in the package, and specify the name of the installer executable? That is, the equivalent of the check box and edit field at the top of the compiler.
When using matlab compiler, is there a way to specify conversion of m files to p code (the ‘-p’ option)?
Also, how do I validate that my compiled executable is using p code rather than m files?
I noticed some behaviour with matlab compiler regarding precedence that I think is contrary to the documentation. If the m files are in the same folder as the main file, then the m files take precedence over p code files, otherwise p code files take precedence. I suspect it is not matlab’s intention that you create the p code files separately prior to compiling the executable, as I could not get this to work using mcc or compiler. I can only get it to work using mcc on m files with the ‘-p’ option on. Some better examples or guidance would help here, as I am testing out lots of different ways to do things in the hope of finding what works.
Apologies if this is too many questions in one post.Hi, I am testing out the matlab compiler and the mcc function. I cannot get a full overlap of functionality between them. For example:
When using the mcc function, is there a way to include matlab runtime in the package, and specify the name of the installer executable? That is, the equivalent of the check box and edit field at the top of the compiler.
When using matlab compiler, is there a way to specify conversion of m files to p code (the ‘-p’ option)?
Also, how do I validate that my compiled executable is using p code rather than m files?
I noticed some behaviour with matlab compiler regarding precedence that I think is contrary to the documentation. If the m files are in the same folder as the main file, then the m files take precedence over p code files, otherwise p code files take precedence. I suspect it is not matlab’s intention that you create the p code files separately prior to compiling the executable, as I could not get this to work using mcc or compiler. I can only get it to work using mcc on m files with the ‘-p’ option on. Some better examples or guidance would help here, as I am testing out lots of different ways to do things in the hope of finding what works.
Apologies if this is too many questions in one post. Hi, I am testing out the matlab compiler and the mcc function. I cannot get a full overlap of functionality between them. For example:
When using the mcc function, is there a way to include matlab runtime in the package, and specify the name of the installer executable? That is, the equivalent of the check box and edit field at the top of the compiler.
When using matlab compiler, is there a way to specify conversion of m files to p code (the ‘-p’ option)?
Also, how do I validate that my compiled executable is using p code rather than m files?
I noticed some behaviour with matlab compiler regarding precedence that I think is contrary to the documentation. If the m files are in the same folder as the main file, then the m files take precedence over p code files, otherwise p code files take precedence. I suspect it is not matlab’s intention that you create the p code files separately prior to compiling the executable, as I could not get this to work using mcc or compiler. I can only get it to work using mcc on m files with the ‘-p’ option on. Some better examples or guidance would help here, as I am testing out lots of different ways to do things in the hope of finding what works.
Apologies if this is too many questions in one post. compiler, mcc, runtime, .p code MATLAB Answers — New Questions
can you please help me how to load only indian map from world
can you please help me how to load only indian map from world?can you please help me how to load only indian map from world? can you please help me how to load only indian map from world? indian map MATLAB Answers — New Questions
figure is not being displayed
I am trying to write a code for a trigeneration system and see the results to make necessary changes yet when i run the code, the output graph is emty and i dont understand why. please help as soon as possible.I am trying to write a code for a trigeneration system and see the results to make necessary changes yet when i run the code, the output graph is emty and i dont understand why. please help as soon as possible. I am trying to write a code for a trigeneration system and see the results to make necessary changes yet when i run the code, the output graph is emty and i dont understand why. please help as soon as possible. matlab, mscript, code, figure, graph MATLAB Answers — New Questions
braking slip controlled EV plant
design of regenerative slip controlled raking system plant for an EV using matlab/simulinkdesign of regenerative slip controlled raking system plant for an EV using matlab/simulink design of regenerative slip controlled raking system plant for an EV using matlab/simulink control MATLAB Answers — New Questions
Please assist to resolve “magaa and mag2a” codes problems; probably FUN and fsolve, not properly sets. The mag2 has to generate 12 (Qy-variable) questions by for-end. Thanks
I have two file execution files, MAGa is main and mag2a is responsible for produce and generate 12 non-linear equations, and probably could goes to 100. The MAGa file has to call mag2a and produce the output in table format. I have failed to known what is main problem, include set up FUN in mag2 file and solver (non-linear) I has proposed. See the attached files and executed output; appreciate your assistance
FILE MAGa and mag2a
MAGa
function [Qy, FUN] = MAGa(Qy0)
tic, n=12; pipes=n; dia=n; LP=4; cCc=7; HLD=-0; ee=0.04; vs=1.00001*10^-6; format shortEng
D=[1.120, 0.059, 0.019, 0.033, 0.060, 0.052, 0.023, 0.029, 0.017, 0.018, 0.058, 0.150]; L=[50, 50, 40, 50, 40, 50, 60, 60, 50, 50, 60, 40];
FUN = @mag2a; %
options = optimoptions(‘fsolve’,’Display’,’iter’,MaxIterations=10000000, MaxFunctionEvaluations=10000000, Algorithm=’levenberg-marquardt’);
% Qy0(1:12,1)=0.30;
[Qy]=fsolve(FUN, Qy0, options);
Len=L(1,:)’; Dia=D(1,:)’; vel=4*Qy(:,1)./(3.14.*Dia(:,1).^2); Re=4.*Qy(:,1)./(3.14*vs.*Dia(:,1));
fy11=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)*0.0001.^0.5)); fy1=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy11.^0.5); fy=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy1.^0.5); f=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy.^0.5); ff=(1./f).^2;
Data1=zeros(n,cCc); Data1(:,1)=Len(:,1); Data1(:,2)=Dia(:,1); Data1(:,3)=Qy(:,1); Data1(:,4)=vel(:,1); Data1(:,5)=ff(:,1); Data1(:,6)=Re(:,1); % Data1,
StrNum={‘string’,’double’,’double’,’double’,’double’,’double’,’double’,’double’}; subTitl={‘Pipes [x-z]’, ‘Length [m]’, ‘Diameter [m]’, ‘Flow rate [m3/s]’, ‘Velocity [m/s]’, ‘Friction, f’, ‘Reynold No.’, ‘Headlosses [m]’}; %
tz=table(‘size’, [n, cCc+1], ‘variabletypes’,StrNum, ‘variablenames’, subTitl); Pipexz=["1P(N1-N2)","2P(N1-N2)","3P(N1-N2)","4P(N1-N2)","5P(N1-N2)","6P(N1-N2)","7P(N1-N2)","8P(N1-N2)","9P(N1-N2)","10P(N1-N2)","11P(N1-N2)","12P(N1-N2)"];
tz{:,1}=Pipexz’; tz{:,2:cCc+1}=Data1(:,1:cCc), toc % MIDsrt=sortrows(tz,sn); MIDfn=MIDsrt; MIDfn(:,end)=[ ];
end
mag2a
function [FUN] = mag2a(D,L,LP,n,ee,vs,matr,HLD)
matr=[1,0,0,0,1,-1,0,0,0,0,0,-1; 0,1,1,-1,-1,0,0,0,0,0,0,0; 0,0,0,1,0,0,1,-1,-1,0,0,0; 0,0,0,0,0,1,0,1,0,-1,-1,0]; LP=4; n=12;
fprintf(‘FUN=@(Qy)[‘);
for j=1:LP, j;
if (j<=4-0)
for k=1:n, k;
if sum(matr(j,1:k))~=sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k), end
if sum(matr(j,1:k))==sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k),
end, end, end
end
fprintf(‘Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];n’); % 1/(Qy(7)).^0.5+4*log(ee./(3.7*D(1,1))+2.54*3.14*D(1,1)*vs./(4*Qy(1)*(Qy(7)).^0.5));…
end
OUTPUT OF EXECUTION (OUTPUTS)
Qy0(1:12,1)=0.30; MAGa(Qy0)
FUN=@(Qy)[1*(Qy(1)*abs(Qy(1)*8*L(1,1)*1./(9.81*3.14.^2*D(1,1).^5)*(-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(12)*abs(Qy(12)*8*L(1,12)*1./(9.81*3.14.^2*D(1,12).^5)*(-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(2)*abs(Qy(2)*8*L(1,2)*1./(9.81*3.14.^2*D(1,2).^5)*(-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(3)*abs(Qy(3)*8*L(1,3)*1./(9.81*3.14.^2*D(1,3).^5)*(-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(7)*abs(Qy(7)*8*L(1,7)*1./(9.81*3.14.^2*D(1,7).^5)*(-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(9)*abs(Qy(9)*8*L(1,9)*1./(9.81*3.14.^2*D(1,9).^5)*(-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(10)*abs(Qy(10)*8*L(1,10)*1./(9.81*3.14.^2*D(1,10).^5)*(-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(11)*abs(Qy(11)*8*L(1,11)*1./(9.81*3.14.^2*D(1,11).^5)*(-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];
Output argument "FUN" (and possibly others) not assigned a value in the execution with "mag2a" function.
Error in fsolve (line 270)
fuser = feval(funfcn{3},x,varargin{:});
Error in MAGa (line 8)
[Qy]=fsolve(FUN, Qy0, options);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
>>I have two file execution files, MAGa is main and mag2a is responsible for produce and generate 12 non-linear equations, and probably could goes to 100. The MAGa file has to call mag2a and produce the output in table format. I have failed to known what is main problem, include set up FUN in mag2 file and solver (non-linear) I has proposed. See the attached files and executed output; appreciate your assistance
FILE MAGa and mag2a
MAGa
function [Qy, FUN] = MAGa(Qy0)
tic, n=12; pipes=n; dia=n; LP=4; cCc=7; HLD=-0; ee=0.04; vs=1.00001*10^-6; format shortEng
D=[1.120, 0.059, 0.019, 0.033, 0.060, 0.052, 0.023, 0.029, 0.017, 0.018, 0.058, 0.150]; L=[50, 50, 40, 50, 40, 50, 60, 60, 50, 50, 60, 40];
FUN = @mag2a; %
options = optimoptions(‘fsolve’,’Display’,’iter’,MaxIterations=10000000, MaxFunctionEvaluations=10000000, Algorithm=’levenberg-marquardt’);
% Qy0(1:12,1)=0.30;
[Qy]=fsolve(FUN, Qy0, options);
Len=L(1,:)’; Dia=D(1,:)’; vel=4*Qy(:,1)./(3.14.*Dia(:,1).^2); Re=4.*Qy(:,1)./(3.14*vs.*Dia(:,1));
fy11=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)*0.0001.^0.5)); fy1=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy11.^0.5); fy=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy1.^0.5); f=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy.^0.5); ff=(1./f).^2;
Data1=zeros(n,cCc); Data1(:,1)=Len(:,1); Data1(:,2)=Dia(:,1); Data1(:,3)=Qy(:,1); Data1(:,4)=vel(:,1); Data1(:,5)=ff(:,1); Data1(:,6)=Re(:,1); % Data1,
StrNum={‘string’,’double’,’double’,’double’,’double’,’double’,’double’,’double’}; subTitl={‘Pipes [x-z]’, ‘Length [m]’, ‘Diameter [m]’, ‘Flow rate [m3/s]’, ‘Velocity [m/s]’, ‘Friction, f’, ‘Reynold No.’, ‘Headlosses [m]’}; %
tz=table(‘size’, [n, cCc+1], ‘variabletypes’,StrNum, ‘variablenames’, subTitl); Pipexz=["1P(N1-N2)","2P(N1-N2)","3P(N1-N2)","4P(N1-N2)","5P(N1-N2)","6P(N1-N2)","7P(N1-N2)","8P(N1-N2)","9P(N1-N2)","10P(N1-N2)","11P(N1-N2)","12P(N1-N2)"];
tz{:,1}=Pipexz’; tz{:,2:cCc+1}=Data1(:,1:cCc), toc % MIDsrt=sortrows(tz,sn); MIDfn=MIDsrt; MIDfn(:,end)=[ ];
end
mag2a
function [FUN] = mag2a(D,L,LP,n,ee,vs,matr,HLD)
matr=[1,0,0,0,1,-1,0,0,0,0,0,-1; 0,1,1,-1,-1,0,0,0,0,0,0,0; 0,0,0,1,0,0,1,-1,-1,0,0,0; 0,0,0,0,0,1,0,1,0,-1,-1,0]; LP=4; n=12;
fprintf(‘FUN=@(Qy)[‘);
for j=1:LP, j;
if (j<=4-0)
for k=1:n, k;
if sum(matr(j,1:k))~=sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k), end
if sum(matr(j,1:k))==sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k),
end, end, end
end
fprintf(‘Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];n’); % 1/(Qy(7)).^0.5+4*log(ee./(3.7*D(1,1))+2.54*3.14*D(1,1)*vs./(4*Qy(1)*(Qy(7)).^0.5));…
end
OUTPUT OF EXECUTION (OUTPUTS)
Qy0(1:12,1)=0.30; MAGa(Qy0)
FUN=@(Qy)[1*(Qy(1)*abs(Qy(1)*8*L(1,1)*1./(9.81*3.14.^2*D(1,1).^5)*(-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(12)*abs(Qy(12)*8*L(1,12)*1./(9.81*3.14.^2*D(1,12).^5)*(-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(2)*abs(Qy(2)*8*L(1,2)*1./(9.81*3.14.^2*D(1,2).^5)*(-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(3)*abs(Qy(3)*8*L(1,3)*1./(9.81*3.14.^2*D(1,3).^5)*(-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(7)*abs(Qy(7)*8*L(1,7)*1./(9.81*3.14.^2*D(1,7).^5)*(-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(9)*abs(Qy(9)*8*L(1,9)*1./(9.81*3.14.^2*D(1,9).^5)*(-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(10)*abs(Qy(10)*8*L(1,10)*1./(9.81*3.14.^2*D(1,10).^5)*(-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(11)*abs(Qy(11)*8*L(1,11)*1./(9.81*3.14.^2*D(1,11).^5)*(-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];
Output argument "FUN" (and possibly others) not assigned a value in the execution with "mag2a" function.
Error in fsolve (line 270)
fuser = feval(funfcn{3},x,varargin{:});
Error in MAGa (line 8)
[Qy]=fsolve(FUN, Qy0, options);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
>> I have two file execution files, MAGa is main and mag2a is responsible for produce and generate 12 non-linear equations, and probably could goes to 100. The MAGa file has to call mag2a and produce the output in table format. I have failed to known what is main problem, include set up FUN in mag2 file and solver (non-linear) I has proposed. See the attached files and executed output; appreciate your assistance
FILE MAGa and mag2a
MAGa
function [Qy, FUN] = MAGa(Qy0)
tic, n=12; pipes=n; dia=n; LP=4; cCc=7; HLD=-0; ee=0.04; vs=1.00001*10^-6; format shortEng
D=[1.120, 0.059, 0.019, 0.033, 0.060, 0.052, 0.023, 0.029, 0.017, 0.018, 0.058, 0.150]; L=[50, 50, 40, 50, 40, 50, 60, 60, 50, 50, 60, 40];
FUN = @mag2a; %
options = optimoptions(‘fsolve’,’Display’,’iter’,MaxIterations=10000000, MaxFunctionEvaluations=10000000, Algorithm=’levenberg-marquardt’);
% Qy0(1:12,1)=0.30;
[Qy]=fsolve(FUN, Qy0, options);
Len=L(1,:)’; Dia=D(1,:)’; vel=4*Qy(:,1)./(3.14.*Dia(:,1).^2); Re=4.*Qy(:,1)./(3.14*vs.*Dia(:,1));
fy11=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)*0.0001.^0.5)); fy1=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy11.^0.5); fy=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy1.^0.5); f=-2*log10(ee./(3.7.*Dia(:,1))+2.51*3.14*vs.*Dia(:,1)./(4.*Qy(:,1)).*fy.^0.5); ff=(1./f).^2;
Data1=zeros(n,cCc); Data1(:,1)=Len(:,1); Data1(:,2)=Dia(:,1); Data1(:,3)=Qy(:,1); Data1(:,4)=vel(:,1); Data1(:,5)=ff(:,1); Data1(:,6)=Re(:,1); % Data1,
StrNum={‘string’,’double’,’double’,’double’,’double’,’double’,’double’,’double’}; subTitl={‘Pipes [x-z]’, ‘Length [m]’, ‘Diameter [m]’, ‘Flow rate [m3/s]’, ‘Velocity [m/s]’, ‘Friction, f’, ‘Reynold No.’, ‘Headlosses [m]’}; %
tz=table(‘size’, [n, cCc+1], ‘variabletypes’,StrNum, ‘variablenames’, subTitl); Pipexz=["1P(N1-N2)","2P(N1-N2)","3P(N1-N2)","4P(N1-N2)","5P(N1-N2)","6P(N1-N2)","7P(N1-N2)","8P(N1-N2)","9P(N1-N2)","10P(N1-N2)","11P(N1-N2)","12P(N1-N2)"];
tz{:,1}=Pipexz’; tz{:,2:cCc+1}=Data1(:,1:cCc), toc % MIDsrt=sortrows(tz,sn); MIDfn=MIDsrt; MIDfn(:,end)=[ ];
end
mag2a
function [FUN] = mag2a(D,L,LP,n,ee,vs,matr,HLD)
matr=[1,0,0,0,1,-1,0,0,0,0,0,-1; 0,1,1,-1,-1,0,0,0,0,0,0,0; 0,0,0,1,0,0,1,-1,-1,0,0,0; 0,0,0,0,0,1,0,1,0,-1,-1,0]; LP=4; n=12;
fprintf(‘FUN=@(Qy)[‘);
for j=1:LP, j;
if (j<=4-0)
for k=1:n, k;
if sum(matr(j,1:k))~=sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k), end
if sum(matr(j,1:k))==sum(matr(j,:))&&matr(j,k)~=0 fprintf(‘%d*(Qy(%d)*abs(Qy(%d)*8*L(1,%d)*1./(9.81*3.14.^2*D(1,%d).^5)*(-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*((-2*log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(1,%d)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;n’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k),
end, end, end
end
fprintf(‘Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];n’); % 1/(Qy(7)).^0.5+4*log(ee./(3.7*D(1,1))+2.54*3.14*D(1,1)*vs./(4*Qy(1)*(Qy(7)).^0.5));…
end
OUTPUT OF EXECUTION (OUTPUTS)
Qy0(1:12,1)=0.30; MAGa(Qy0)
FUN=@(Qy)[1*(Qy(1)*abs(Qy(1)*8*L(1,1)*1./(9.81*3.14.^2*D(1,1).^5)*(-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*((-2*log10(ee./(3.7.*D(1,1))+2.51*3.14*vs.*D(1,1)./(4.*Qy(1,1)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(12)*abs(Qy(12)*8*L(1,12)*1./(9.81*3.14.^2*D(1,12).^5)*(-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*((-2*log10(ee./(3.7.*D(1,12))+2.51*3.14*vs.*D(1,12)./(4.*Qy(1,12)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(2)*abs(Qy(2)*8*L(1,2)*1./(9.81*3.14.^2*D(1,2).^5)*(-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*((-2*log10(ee./(3.7.*D(1,2))+2.51*3.14*vs.*D(1,2)./(4.*Qy(1,2)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(3)*abs(Qy(3)*8*L(1,3)*1./(9.81*3.14.^2*D(1,3).^5)*(-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*((-2*log10(ee./(3.7.*D(1,3))+2.51*3.14*vs.*D(1,3)./(4.*Qy(1,3)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(5)*abs(Qy(5)*8*L(1,5)*1./(9.81*3.14.^2*D(1,5).^5)*(-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*((-2*log10(ee./(3.7.*D(1,5))+2.51*3.14*vs.*D(1,5)./(4.*Qy(1,5)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(4)*abs(Qy(4)*8*L(1,4)*1./(9.81*3.14.^2*D(1,4).^5)*(-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*((-2*log10(ee./(3.7.*D(1,4))+2.51*3.14*vs.*D(1,4)./(4.*Qy(1,4)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(7)*abs(Qy(7)*8*L(1,7)*1./(9.81*3.14.^2*D(1,7).^5)*(-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*((-2*log10(ee./(3.7.*D(1,7))+2.51*3.14*vs.*D(1,7)./(4.*Qy(1,7)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(9)*abs(Qy(9)*8*L(1,9)*1./(9.81*3.14.^2*D(1,9).^5)*(-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*((-2*log10(ee./(3.7.*D(1,9))+2.51*3.14*vs.*D(1,9)./(4.*Qy(1,9)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
1*(Qy(6)*abs(Qy(6)*8*L(1,6)*1./(9.81*3.14.^2*D(1,6).^5)*(-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*((-2*log10(ee./(3.7.*D(1,6))+2.51*3.14*vs.*D(1,6)./(4.*Qy(1,6)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
1*(Qy(8)*abs(Qy(8)*8*L(1,8)*1./(9.81*3.14.^2*D(1,8).^5)*(-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*((-2*log10(ee./(3.7.*D(1,8))+2.51*3.14*vs.*D(1,8)./(4.*Qy(1,8)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(10)*abs(Qy(10)*8*L(1,10)*1./(9.81*3.14.^2*D(1,10).^5)*(-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*((-2*log10(ee./(3.7.*D(1,10))+2.51*3.14*vs.*D(1,10)./(4.*Qy(1,10)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2+…
-1*(Qy(11)*abs(Qy(11)*8*L(1,11)*1./(9.81*3.14.^2*D(1,11).^5)*(-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*((-2*log10(ee./(3.7.*D(1,11))+2.51*3.14*vs.*D(1,11)./(4.*Qy(1,11)*(0.0001).^0.5)))).^0.5)))).^0.5))).^-2;
Qy(1)-Qy(2)-Qy(5)-0.03; Qy(2)-Qy(3)-0.04; Qy(3)+Qy(4)-Qy(7)-0.03; Qy(6)+Qy(5)-Qy(4)-Qy(8)-0.05; Qy(7)+Qy(9)-0.04; Qy(8)+Qy(10)-Qy(9)-0.03; Qy(11)-Qy(10)-0.04; Qy(12)-Qy(6)-Qy(11)-0.04];
Output argument "FUN" (and possibly others) not assigned a value in the execution with "mag2a" function.
Error in fsolve (line 270)
fuser = feval(funfcn{3},x,varargin{:});
Error in MAGa (line 8)
[Qy]=fsolve(FUN, Qy0, options);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
>> fsolve MATLAB Answers — New Questions
how to get reference in app designer
i’m in Predator_Equity.Mlapp and i create Lista_strategieAggreg using:
Lista_stratzegieAggreg(app);
it’s possible to receive referenze of this app?
example: xx=Lista_stratzegieAggreg(app);
but it doesn’t run
Why do I need it? because when I create Lista_strategie Aggreg I want to update a value in the panel (where there is the red arrow in the photo I have to update the text box) and to do so I need the referencei’m in Predator_Equity.Mlapp and i create Lista_strategieAggreg using:
Lista_stratzegieAggreg(app);
it’s possible to receive referenze of this app?
example: xx=Lista_stratzegieAggreg(app);
but it doesn’t run
Why do I need it? because when I create Lista_strategie Aggreg I want to update a value in the panel (where there is the red arrow in the photo I have to update the text box) and to do so I need the reference i’m in Predator_Equity.Mlapp and i create Lista_strategieAggreg using:
Lista_stratzegieAggreg(app);
it’s possible to receive referenze of this app?
example: xx=Lista_stratzegieAggreg(app);
but it doesn’t run
Why do I need it? because when I create Lista_strategie Aggreg I want to update a value in the panel (where there is the red arrow in the photo I have to update the text box) and to do so I need the reference how to get reference in app designer MATLAB Answers — New Questions
Particle Filter block of SImulink is not accepting my 6*1 measurement matrix
I am working on a system whose state sapce model is defined as follows:
x = A*x + B*u;
y = C*x;
where, x is state variable with dimension (15*1), y is the output variable with dimension (6*1) and u is the input variable with dimension (3*1). The dimensions of matrices A, B and C are (15*15), (15*3) and (6*15), respectively. I want to implement the Particle Filter block of MATLAB simulink for state estimation of this system. The simulink model of the Particle Filter is given below:
Fig 1
The Particle Filter configuration parameters are given below in Fig 2.
Fig 2.
When I run the simulation, it shows the following error:
Please help me debug the above problem.I am working on a system whose state sapce model is defined as follows:
x = A*x + B*u;
y = C*x;
where, x is state variable with dimension (15*1), y is the output variable with dimension (6*1) and u is the input variable with dimension (3*1). The dimensions of matrices A, B and C are (15*15), (15*3) and (6*15), respectively. I want to implement the Particle Filter block of MATLAB simulink for state estimation of this system. The simulink model of the Particle Filter is given below:
Fig 1
The Particle Filter configuration parameters are given below in Fig 2.
Fig 2.
When I run the simulation, it shows the following error:
Please help me debug the above problem. I am working on a system whose state sapce model is defined as follows:
x = A*x + B*u;
y = C*x;
where, x is state variable with dimension (15*1), y is the output variable with dimension (6*1) and u is the input variable with dimension (3*1). The dimensions of matrices A, B and C are (15*15), (15*3) and (6*15), respectively. I want to implement the Particle Filter block of MATLAB simulink for state estimation of this system. The simulink model of the Particle Filter is given below:
Fig 1
The Particle Filter configuration parameters are given below in Fig 2.
Fig 2.
When I run the simulation, it shows the following error:
Please help me debug the above problem. particle filter MATLAB Answers — New Questions
what am i doing wrong?
a = [6.935619321 6.044821712 3.134221992 4.03723168 44.35409695 24.3929123 27.83599663 2.360239752 31.63092825 7.189890853 0.639270435 1.404702752 87.21610528 7.956564044 4.976439534 14.98701648 20.04658871 3.245097342 60.65204845 8.473849158 12.88126928 152.5899599 162.5176806 165.3003645 172.9442562 36.1144365 17.27680243 13.61212521 35.61080325 12.91920333 4.060340798 5.183427853 16.82114757 21.53888165 30.87388237 0.500171677 13.90364604 18.71917525 12.20078559 35.42235807 2.360556574 5.146571947 0.688984049 0.571231374 10.98994753 0.610325415 16.73235181 28.38199434 49.11590007 37.24850295 4.96158691 30.82454871 8.600581955 18.60764689 44.97155227 6.267863223 1.29369648 80.35825674 50.37336917 120.402486
704.7425374 497.8575062 231.0523862 303.9155734 2398.86889 2363.393303 2052.214632 1401.527665 1195.385704 1141.068931 530.1204071 719.0627586 658.2118105 1670.911183 964.4133012 613.2864152 651.5200114 1032.004328 883.933512 926.9718212 669.3164675 855.1756096 877.7346682 873.1162954 852.6209747 870.9879069 2228.003245 835.1785985 495.4477079 2145.984107 980.4355009 1184.624074 354.6949055 444.278561 809.808274 1070.888888 1208.93713 130.9940865 532.878654 692.6306627 828.6450502 628.5106037 748.6055007 786.6259368 885.2770485 933.6825812 851.4713508 1035.56264 884.3207665 1159.39765 1312.298832 1862.273744 271.4662628 562.0994173 347.4607626 2316.859913 485.7127394 399.7244779 1237.155371 1478.748961
-841.7576842 -535.4401458 -492.1288074 -385.4577355 -2610.862233 -472.6483553 -423.2464952 -2812.842669 -2427.79961 -2235.386912 -1690.107759 -1626.896759 -257.4801241 -3329.131946 -2816.665045 -1218.245293 -728.4260221 -1227.67158 -1397.417942 -1363.334056 -1092.449912 -1208.551645 -1102.110806 -1160.550311 -1007.357699 -1157.746282 -1345.887656 -2679.35944 -1226.720221 -2617.088883 -2738.784324 -1261.888107 -490.367718 -716.0875752 -457.6734926 -538.4369091 -773.0059077 -1498.429036 -1446.717147 -1746.137904 -1961.961576 -134.6617489 -1178.250329 -1312.036393 -341.3551273 -686.7375961 -846.7331219 -954.3391692 -106.2146133 -1271.62049 -1178.210577 -2191.348181 -1944.777367 -641.3823654 -915.4784362 -678.3189285 -2481.942741 -2654.875547 -591.1355787 -437.3663647
4862.910289 1355.933205 1740.109509 697.266154 10957.77786 20938.3703 3942.430228 312.8555661 7835.792313 2051.919986 179.9962327 27454.99512 20558.87867 -20481.51341 -921.0031122 3468.856724 25559.93643 714.210672 12542.34206 4634.476687 50754.55309 23954.5459 30343.97296 36195.75984 49421.33637 -49706.22754 5029.02627 2461.715672 -74020.41277 -3078.082319 673.2815554 1659.872489 4132.459252 6291.012785 7587.811162 104.6994939 1976.167568 5056.462596 3920.106703 9410.246322 591.1871644 -2207.887378 107.0944364 86.73960378 1894.612108 161.7588786 3030.729399 10092.23733 17197.12127 72133.96032 1163.169661 4682.375674 17574.82174 3891.35099 24981.90974 -2283.196074 261.7046238 11028.39779 17849.93272 21717.11903
-677.7197919 -319.6740693 -71.42845025 -207.168951 -752.3694602 -877.2136527 -386.8745055 -45.27745973 -526.6557927 -125.4235623 -18.68792141 1975.357795 -490.7437904 -1383.403587 -129.5860491 -163.1735662 -302.2616691 -90.66935992 -602.3054636 -138.6030629 -221.7409722 -1286.176506 -1304.778913 -1301.634913 -1339.894613 -593.4283686 -243.6596197 -216.8395299 -577.2791256 -397.6489027 -67.06907873 -83.43416971 -289.3598963 -266.6904773 -319.4891615 -27.11016096 -2570.197199 -270.8016951 -199.2744951 -580.5057735 -77.01200107 -471.0391248 -36.41676677 -31.92916616 -183.4049563 -82.08328851 -262.4306585 -265.7770551 -351.7104009 -579.6475265 -92.16428519 -332.8595157 -173.2395123 -267.0596267 -493.5616198 -1712.910856 75.48626306 -401.6144294 -415.2271257 -4048.657506];
f1 = (.01 + .1)/2;
f2 = (2 + 4)/2;
f3 = (1 + 5)/2; % centre frequency in Hz
f4 = (5 + 10)/2;
f5 = (.1+1)/2;
Q = []
for i = 1:size(a(:,i))
q(:,i) = a(:,i);
b1 = log(q(:,i));
b2 = log([f1 f2 f3 f4 f5]’);
p = abs(polyfit(b2, b1, 2));
n = abs(p(1));
q0 = abs(exp(p(2)));
Q(:,i) = q0 * [f1 f2 f3 f4 f5]’.^n;
i = i + 1;
enda = [6.935619321 6.044821712 3.134221992 4.03723168 44.35409695 24.3929123 27.83599663 2.360239752 31.63092825 7.189890853 0.639270435 1.404702752 87.21610528 7.956564044 4.976439534 14.98701648 20.04658871 3.245097342 60.65204845 8.473849158 12.88126928 152.5899599 162.5176806 165.3003645 172.9442562 36.1144365 17.27680243 13.61212521 35.61080325 12.91920333 4.060340798 5.183427853 16.82114757 21.53888165 30.87388237 0.500171677 13.90364604 18.71917525 12.20078559 35.42235807 2.360556574 5.146571947 0.688984049 0.571231374 10.98994753 0.610325415 16.73235181 28.38199434 49.11590007 37.24850295 4.96158691 30.82454871 8.600581955 18.60764689 44.97155227 6.267863223 1.29369648 80.35825674 50.37336917 120.402486
704.7425374 497.8575062 231.0523862 303.9155734 2398.86889 2363.393303 2052.214632 1401.527665 1195.385704 1141.068931 530.1204071 719.0627586 658.2118105 1670.911183 964.4133012 613.2864152 651.5200114 1032.004328 883.933512 926.9718212 669.3164675 855.1756096 877.7346682 873.1162954 852.6209747 870.9879069 2228.003245 835.1785985 495.4477079 2145.984107 980.4355009 1184.624074 354.6949055 444.278561 809.808274 1070.888888 1208.93713 130.9940865 532.878654 692.6306627 828.6450502 628.5106037 748.6055007 786.6259368 885.2770485 933.6825812 851.4713508 1035.56264 884.3207665 1159.39765 1312.298832 1862.273744 271.4662628 562.0994173 347.4607626 2316.859913 485.7127394 399.7244779 1237.155371 1478.748961
-841.7576842 -535.4401458 -492.1288074 -385.4577355 -2610.862233 -472.6483553 -423.2464952 -2812.842669 -2427.79961 -2235.386912 -1690.107759 -1626.896759 -257.4801241 -3329.131946 -2816.665045 -1218.245293 -728.4260221 -1227.67158 -1397.417942 -1363.334056 -1092.449912 -1208.551645 -1102.110806 -1160.550311 -1007.357699 -1157.746282 -1345.887656 -2679.35944 -1226.720221 -2617.088883 -2738.784324 -1261.888107 -490.367718 -716.0875752 -457.6734926 -538.4369091 -773.0059077 -1498.429036 -1446.717147 -1746.137904 -1961.961576 -134.6617489 -1178.250329 -1312.036393 -341.3551273 -686.7375961 -846.7331219 -954.3391692 -106.2146133 -1271.62049 -1178.210577 -2191.348181 -1944.777367 -641.3823654 -915.4784362 -678.3189285 -2481.942741 -2654.875547 -591.1355787 -437.3663647
4862.910289 1355.933205 1740.109509 697.266154 10957.77786 20938.3703 3942.430228 312.8555661 7835.792313 2051.919986 179.9962327 27454.99512 20558.87867 -20481.51341 -921.0031122 3468.856724 25559.93643 714.210672 12542.34206 4634.476687 50754.55309 23954.5459 30343.97296 36195.75984 49421.33637 -49706.22754 5029.02627 2461.715672 -74020.41277 -3078.082319 673.2815554 1659.872489 4132.459252 6291.012785 7587.811162 104.6994939 1976.167568 5056.462596 3920.106703 9410.246322 591.1871644 -2207.887378 107.0944364 86.73960378 1894.612108 161.7588786 3030.729399 10092.23733 17197.12127 72133.96032 1163.169661 4682.375674 17574.82174 3891.35099 24981.90974 -2283.196074 261.7046238 11028.39779 17849.93272 21717.11903
-677.7197919 -319.6740693 -71.42845025 -207.168951 -752.3694602 -877.2136527 -386.8745055 -45.27745973 -526.6557927 -125.4235623 -18.68792141 1975.357795 -490.7437904 -1383.403587 -129.5860491 -163.1735662 -302.2616691 -90.66935992 -602.3054636 -138.6030629 -221.7409722 -1286.176506 -1304.778913 -1301.634913 -1339.894613 -593.4283686 -243.6596197 -216.8395299 -577.2791256 -397.6489027 -67.06907873 -83.43416971 -289.3598963 -266.6904773 -319.4891615 -27.11016096 -2570.197199 -270.8016951 -199.2744951 -580.5057735 -77.01200107 -471.0391248 -36.41676677 -31.92916616 -183.4049563 -82.08328851 -262.4306585 -265.7770551 -351.7104009 -579.6475265 -92.16428519 -332.8595157 -173.2395123 -267.0596267 -493.5616198 -1712.910856 75.48626306 -401.6144294 -415.2271257 -4048.657506];
f1 = (.01 + .1)/2;
f2 = (2 + 4)/2;
f3 = (1 + 5)/2; % centre frequency in Hz
f4 = (5 + 10)/2;
f5 = (.1+1)/2;
Q = []
for i = 1:size(a(:,i))
q(:,i) = a(:,i);
b1 = log(q(:,i));
b2 = log([f1 f2 f3 f4 f5]’);
p = abs(polyfit(b2, b1, 2));
n = abs(p(1));
q0 = abs(exp(p(2)));
Q(:,i) = q0 * [f1 f2 f3 f4 f5]’.^n;
i = i + 1;
end a = [6.935619321 6.044821712 3.134221992 4.03723168 44.35409695 24.3929123 27.83599663 2.360239752 31.63092825 7.189890853 0.639270435 1.404702752 87.21610528 7.956564044 4.976439534 14.98701648 20.04658871 3.245097342 60.65204845 8.473849158 12.88126928 152.5899599 162.5176806 165.3003645 172.9442562 36.1144365 17.27680243 13.61212521 35.61080325 12.91920333 4.060340798 5.183427853 16.82114757 21.53888165 30.87388237 0.500171677 13.90364604 18.71917525 12.20078559 35.42235807 2.360556574 5.146571947 0.688984049 0.571231374 10.98994753 0.610325415 16.73235181 28.38199434 49.11590007 37.24850295 4.96158691 30.82454871 8.600581955 18.60764689 44.97155227 6.267863223 1.29369648 80.35825674 50.37336917 120.402486
704.7425374 497.8575062 231.0523862 303.9155734 2398.86889 2363.393303 2052.214632 1401.527665 1195.385704 1141.068931 530.1204071 719.0627586 658.2118105 1670.911183 964.4133012 613.2864152 651.5200114 1032.004328 883.933512 926.9718212 669.3164675 855.1756096 877.7346682 873.1162954 852.6209747 870.9879069 2228.003245 835.1785985 495.4477079 2145.984107 980.4355009 1184.624074 354.6949055 444.278561 809.808274 1070.888888 1208.93713 130.9940865 532.878654 692.6306627 828.6450502 628.5106037 748.6055007 786.6259368 885.2770485 933.6825812 851.4713508 1035.56264 884.3207665 1159.39765 1312.298832 1862.273744 271.4662628 562.0994173 347.4607626 2316.859913 485.7127394 399.7244779 1237.155371 1478.748961
-841.7576842 -535.4401458 -492.1288074 -385.4577355 -2610.862233 -472.6483553 -423.2464952 -2812.842669 -2427.79961 -2235.386912 -1690.107759 -1626.896759 -257.4801241 -3329.131946 -2816.665045 -1218.245293 -728.4260221 -1227.67158 -1397.417942 -1363.334056 -1092.449912 -1208.551645 -1102.110806 -1160.550311 -1007.357699 -1157.746282 -1345.887656 -2679.35944 -1226.720221 -2617.088883 -2738.784324 -1261.888107 -490.367718 -716.0875752 -457.6734926 -538.4369091 -773.0059077 -1498.429036 -1446.717147 -1746.137904 -1961.961576 -134.6617489 -1178.250329 -1312.036393 -341.3551273 -686.7375961 -846.7331219 -954.3391692 -106.2146133 -1271.62049 -1178.210577 -2191.348181 -1944.777367 -641.3823654 -915.4784362 -678.3189285 -2481.942741 -2654.875547 -591.1355787 -437.3663647
4862.910289 1355.933205 1740.109509 697.266154 10957.77786 20938.3703 3942.430228 312.8555661 7835.792313 2051.919986 179.9962327 27454.99512 20558.87867 -20481.51341 -921.0031122 3468.856724 25559.93643 714.210672 12542.34206 4634.476687 50754.55309 23954.5459 30343.97296 36195.75984 49421.33637 -49706.22754 5029.02627 2461.715672 -74020.41277 -3078.082319 673.2815554 1659.872489 4132.459252 6291.012785 7587.811162 104.6994939 1976.167568 5056.462596 3920.106703 9410.246322 591.1871644 -2207.887378 107.0944364 86.73960378 1894.612108 161.7588786 3030.729399 10092.23733 17197.12127 72133.96032 1163.169661 4682.375674 17574.82174 3891.35099 24981.90974 -2283.196074 261.7046238 11028.39779 17849.93272 21717.11903
-677.7197919 -319.6740693 -71.42845025 -207.168951 -752.3694602 -877.2136527 -386.8745055 -45.27745973 -526.6557927 -125.4235623 -18.68792141 1975.357795 -490.7437904 -1383.403587 -129.5860491 -163.1735662 -302.2616691 -90.66935992 -602.3054636 -138.6030629 -221.7409722 -1286.176506 -1304.778913 -1301.634913 -1339.894613 -593.4283686 -243.6596197 -216.8395299 -577.2791256 -397.6489027 -67.06907873 -83.43416971 -289.3598963 -266.6904773 -319.4891615 -27.11016096 -2570.197199 -270.8016951 -199.2744951 -580.5057735 -77.01200107 -471.0391248 -36.41676677 -31.92916616 -183.4049563 -82.08328851 -262.4306585 -265.7770551 -351.7104009 -579.6475265 -92.16428519 -332.8595157 -173.2395123 -267.0596267 -493.5616198 -1712.910856 75.48626306 -401.6144294 -415.2271257 -4048.657506];
f1 = (.01 + .1)/2;
f2 = (2 + 4)/2;
f3 = (1 + 5)/2; % centre frequency in Hz
f4 = (5 + 10)/2;
f5 = (.1+1)/2;
Q = []
for i = 1:size(a(:,i))
q(:,i) = a(:,i);
b1 = log(q(:,i));
b2 = log([f1 f2 f3 f4 f5]’);
p = abs(polyfit(b2, b1, 2));
n = abs(p(1));
q0 = abs(exp(p(2)));
Q(:,i) = q0 * [f1 f2 f3 f4 f5]’.^n;
i = i + 1;
end loop MATLAB Answers — New Questions
cell linked method in matlab with parallelization trough domain splitting
I want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)
I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh
function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)
h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];
idx = floor(ptcls.x./h) + 1;
indexPtcls = 1:size(ptcls.x,2);
grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});
end
Once I have the cell array I am easily able to run trough not empty cells and perform force calculation
index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);
index = find(index >=1);
for i=index(:)
% calculation of the force
end
My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way
If possible would be usefull to have a simple example, thanks in advanceI want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)
I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh
function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)
h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];
idx = floor(ptcls.x./h) + 1;
indexPtcls = 1:size(ptcls.x,2);
grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});
end
Once I have the cell array I am easily able to run trough not empty cells and perform force calculation
index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);
index = find(index >=1);
for i=index(:)
% calculation of the force
end
My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way
If possible would be usefull to have a simple example, thanks in advance I want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)
I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh
function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)
h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];
idx = floor(ptcls.x./h) + 1;
indexPtcls = 1:size(ptcls.x,2);
grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});
end
Once I have the cell array I am easily able to run trough not empty cells and perform force calculation
index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);
index = find(index >=1);
for i=index(:)
% calculation of the force
end
My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way
If possible would be usefull to have a simple example, thanks in advance parallel computing toolbox, linked cell method, particle simulation MATLAB Answers — New Questions
How to create variable length buffer in Simulink for holding the value with unknown dimensions ?
i want to store a value of one signal in Simulink until the my trigger becomes high. Every time when trigger becomes high, the number of values of signal between two triggers are different.
i tried to use the following approach in MATLAB function block but it didn’t worked
function = func(trigger , SignalA)
persistent store;
if isempty(store)
store=[];
end
if(trigger ==0)
store= [store SignalA];
end
end
it gives me following error
Assigning empty arrays to persistent variables is not supported.
Any other method to do this thing?i want to store a value of one signal in Simulink until the my trigger becomes high. Every time when trigger becomes high, the number of values of signal between two triggers are different.
i tried to use the following approach in MATLAB function block but it didn’t worked
function = func(trigger , SignalA)
persistent store;
if isempty(store)
store=[];
end
if(trigger ==0)
store= [store SignalA];
end
end
it gives me following error
Assigning empty arrays to persistent variables is not supported.
Any other method to do this thing? i want to store a value of one signal in Simulink until the my trigger becomes high. Every time when trigger becomes high, the number of values of signal between two triggers are different.
i tried to use the following approach in MATLAB function block but it didn’t worked
function = func(trigger , SignalA)
persistent store;
if isempty(store)
store=[];
end
if(trigger ==0)
store= [store SignalA];
end
end
it gives me following error
Assigning empty arrays to persistent variables is not supported.
Any other method to do this thing? reate variable length buffer in simulink MATLAB Answers — New Questions
I want to differentiate NAA with respect to U(L,J+1), how to do it.
%———————SPLINE IN COMPRESSION————————————————
% Numerical Solution of Burger’s Huxley equation
%E*Uxx=Ut+ALPHA*UUx+BETA*(U^3+DELTA*U^2+GAMMA*U)
% , U(x,t)=GAMMA*[1+tanh(a1*(x-a2*t))]/2, t>=0
%————————————————————————–
clear all; % clear all variables in memory
LAM=1.6;
%LL=10;
%JJ=1000; % Solution at t=1
LL=8;
JJ=40;
H=1/LL;
K=LAM*H*H;
K=0.01;
%LLL=(LL/10)+9;
H= (2*pi)/100;
SGM=1.0;
EPS=1.0;
ALPHA=1.0;
BETA=0.0;
GAMMA=0.0;
DELTA=1.0;
a= (-1/4)*(1-SGM+(SGM)^2);
b= -SGM/(3*(1+SGM));
c= (-1/(2*SGM*(1+SGM)))*(1-SGM+(SGM)^2);
%a1=GAMMA*(-ALPHA+sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA*GAMMA/2)+((2-GAMMA)*(ALPHA+sqrt((ALPHA^2)+8*BETA))/4);
%a1=(-ALPHA-sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA/2)-((1-2*GAMMA)*(ALPHA-sqrt((ALPHA^2)+8*BETA))/4);
% LLL=(0.5*LL)+1;
%tt=(8.986818916*pi)/180;
%tt=8.986818916;
% %Spline in Tension
% tt=0.001;
% AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
% BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
% BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
% CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
% %spline in compression
tt=(8.986818916*pi)/180;
AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
%Cubic Spline
%AA=SGM/3;
%BB1=SGM/6;
%BB2=1/6;
%CC=1/3;
disp(‘Numerical Solution of 1D Parabolic Equation’);
disp(‘ ‘);
fprintf(‘LL=%4.2f, K=%6.4f, LAM=%6.2f n’,LL,K,LAM);
disp(‘ ‘);
% Dimensions
X=zeros(1,LL+1);
T=zeros(1,JJ+1);
TT=zeros(1,JJ+1);
U=zeros(LL+1,JJ+1);
EU=zeros(LL+1,JJ+1);
OLDU=zeros(LL+1,JJ+1);
H=zeros(1,LL);
if SGM==1
S=1;
for i=1:LL-1
S=S+SGM^i;
end;
% H(1)=2/S;
H(1)=1/S;
else
% H(1)=2*((1-SGM)/(1-(SGM^LL)));
H(1)=((1-SGM)/(1-(SGM^LL)));
end
% Formation of Variable step lengths
for L=1:LL-1
H(L+1)=SGM*H(L);
end
% Formation of Nodal Points
% X(1)=-1.0;
X(1)=0.0;
for L=2:LL
for J=1:JJ+1
X(L)=X(L-1)+H(L-1);
T(J)=(J-1)*K;
end
end
X(LL+1)=1.0;
for L=1:LL+1
for J=1:JJ+1
% EU(L,J)=GAMMA*(1+tanh(a1*(X(L)-a2*T(J))))/2;
% EU(L,J)=(1+tanh(a1*(X(L)-a2*T(J))))/2;
EU(L,J)= exp(-T(J))*sin(X(L));
end
end
% Initial conditions
for L=1:LL+1
%U(L,1)=EU(L,1);
U(L,1)=cos(pi*X(L));
end
% Boundary conditions
for J=2:JJ+1
%U(0,J)==EU(0,J);
U(1,J)=exp(-EPS*(pi)^2*T(J));
U(2,J)=-exp(-EPS*(pi)^2*T(J));
%U(1,J)=EU(1,J)==-exp(-EPS*(pi)^2*t);;
U(LL+1,J)=EU(LL+1,J);
end
% Solution at advanced time level
tic % CPU time starts
for J=1:JJ
% Initial & First Approx
for L=2:LL
OLDU(L,J+1)=EU(L,J+1);
U(L,J+1)=OLDU(L,J+1);
end
for KK=1:1200 %Iteration starts
% Solution at Internal grid points at each time level
for L=2:LL
M1 = U(L+1,J+1);
M2 = U(L+1,J);
M3 = U(L,J+1);
M4 = U(L,J);
M5 = U(L-1,J+1);
M6 = U(L-1,J);
N1 = (1/(2*K))*(M5+M3-M6-M4);
N2 = (M5+M3+M6+M4)*(M5+M3+M6+M4-2)*(M5+M3+M6+M4-2*GAMMA);
N3 = (M5+M3++M6+M4);
N4 = (1/(2*SGM*H(L)))*(M5+M6-M3-M4);
N5 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M5+M6-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M1+M2));
N6 = (1/(2*K))*(M5+M3-M6-M4)+(ALPHA/8)*(M5+M6+M3+M4)*(M5+M6+M3+M4)+(BETA/64)*(M5+M6+M3+M4)*(M5+M6+M3+M4-4)*(M5+M6+M3+M4-4*GAMMA);
N7 = (1/(2*K))*(M1+M3-M2-M4);
N8 = (M1+M3+M2+M4)*(M1+M3+M2+M4-2)*(M1+M3+M2+M4-2*GAMMA);
N9 = (M1+M3++M2+M4);
N10 = (1/(2*SGM*H(L)))*(M1+M2-M3-M4);
N11 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M1+M2-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M5+M6));
N12 = (1/(2*K))*(M1+M3-M2-M4)+(ALPHA/8)*(M1+M2+M3+M4)*(M1+M2+M3+M4)+(BETA/64)*(M1+M2+M3+M4)*(M1+M2+M3+M4-4)*(M1+M2+M3+M4-4*GAMMA);
N13 = (1/K)*(M3-M4);
N14 = (1/K)*(M1-M2)-(1+SGM)*N13+(SGM/K)*(M5-M6);
N15= (M3+M4)/(2);
N16 = M1+M2+(1+SGM)*(M3+M4)+SGM*(M5+M6);
N17 = M1+M2-(1-(SGM^2))*(M3+M4)-(SGM)^2*(M5+M6);
N18 = (1/(2*K))*(M1+M3-M2-M4);
N19 =N9^2;
N21 = M5+M3-M6-M4;
N22 = N3^2;
O1 = N1+(BETA/16)*(N2)+(ALPHA/4)*(N3)*(N4+(H(L)/4)*(2*BB2*N5-CC*N6));
O2 = N7+(BETA/16)*(N8)+(ALPHA/4)*(N9)*(N10+(H(L)/4)*(2*BB1*N11-AA*N12));
O3 = N13+c*N14+ALPHA*(N15+(a/SGM*(1+SGM))*N16)*(1/2*H(L)*SGM*(1+SGM))*N17 + b*H(L)*[N18+(ALPHA/8)*N19 + (BETA/16)*N9*(N9-4)*(N9-4*GAMMA)-(N21+(ALPHA/8)*(N3)^2)+(BETA/16)*(N3)*(N3-4)*(N3-4*GAMMA)]+BETA*[(N15+(a/(SGM*(SGM+1)))*N16)*(N15+(a/(2*SGM*(SGM+1)))*N16-1)*(N15+(a/(2*SGM*(SGM+1)))*N16-GAMMA)];
NAA = (EPS/2)*(M1+M2-2*M3-2*M4+M5+M6) – ((H.^2)/3)* (O1+O2+O3);%———————SPLINE IN COMPRESSION————————————————
% Numerical Solution of Burger’s Huxley equation
%E*Uxx=Ut+ALPHA*UUx+BETA*(U^3+DELTA*U^2+GAMMA*U)
% , U(x,t)=GAMMA*[1+tanh(a1*(x-a2*t))]/2, t>=0
%————————————————————————–
clear all; % clear all variables in memory
LAM=1.6;
%LL=10;
%JJ=1000; % Solution at t=1
LL=8;
JJ=40;
H=1/LL;
K=LAM*H*H;
K=0.01;
%LLL=(LL/10)+9;
H= (2*pi)/100;
SGM=1.0;
EPS=1.0;
ALPHA=1.0;
BETA=0.0;
GAMMA=0.0;
DELTA=1.0;
a= (-1/4)*(1-SGM+(SGM)^2);
b= -SGM/(3*(1+SGM));
c= (-1/(2*SGM*(1+SGM)))*(1-SGM+(SGM)^2);
%a1=GAMMA*(-ALPHA+sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA*GAMMA/2)+((2-GAMMA)*(ALPHA+sqrt((ALPHA^2)+8*BETA))/4);
%a1=(-ALPHA-sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA/2)-((1-2*GAMMA)*(ALPHA-sqrt((ALPHA^2)+8*BETA))/4);
% LLL=(0.5*LL)+1;
%tt=(8.986818916*pi)/180;
%tt=8.986818916;
% %Spline in Tension
% tt=0.001;
% AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
% BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
% BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
% CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
% %spline in compression
tt=(8.986818916*pi)/180;
AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
%Cubic Spline
%AA=SGM/3;
%BB1=SGM/6;
%BB2=1/6;
%CC=1/3;
disp(‘Numerical Solution of 1D Parabolic Equation’);
disp(‘ ‘);
fprintf(‘LL=%4.2f, K=%6.4f, LAM=%6.2f n’,LL,K,LAM);
disp(‘ ‘);
% Dimensions
X=zeros(1,LL+1);
T=zeros(1,JJ+1);
TT=zeros(1,JJ+1);
U=zeros(LL+1,JJ+1);
EU=zeros(LL+1,JJ+1);
OLDU=zeros(LL+1,JJ+1);
H=zeros(1,LL);
if SGM==1
S=1;
for i=1:LL-1
S=S+SGM^i;
end;
% H(1)=2/S;
H(1)=1/S;
else
% H(1)=2*((1-SGM)/(1-(SGM^LL)));
H(1)=((1-SGM)/(1-(SGM^LL)));
end
% Formation of Variable step lengths
for L=1:LL-1
H(L+1)=SGM*H(L);
end
% Formation of Nodal Points
% X(1)=-1.0;
X(1)=0.0;
for L=2:LL
for J=1:JJ+1
X(L)=X(L-1)+H(L-1);
T(J)=(J-1)*K;
end
end
X(LL+1)=1.0;
for L=1:LL+1
for J=1:JJ+1
% EU(L,J)=GAMMA*(1+tanh(a1*(X(L)-a2*T(J))))/2;
% EU(L,J)=(1+tanh(a1*(X(L)-a2*T(J))))/2;
EU(L,J)= exp(-T(J))*sin(X(L));
end
end
% Initial conditions
for L=1:LL+1
%U(L,1)=EU(L,1);
U(L,1)=cos(pi*X(L));
end
% Boundary conditions
for J=2:JJ+1
%U(0,J)==EU(0,J);
U(1,J)=exp(-EPS*(pi)^2*T(J));
U(2,J)=-exp(-EPS*(pi)^2*T(J));
%U(1,J)=EU(1,J)==-exp(-EPS*(pi)^2*t);;
U(LL+1,J)=EU(LL+1,J);
end
% Solution at advanced time level
tic % CPU time starts
for J=1:JJ
% Initial & First Approx
for L=2:LL
OLDU(L,J+1)=EU(L,J+1);
U(L,J+1)=OLDU(L,J+1);
end
for KK=1:1200 %Iteration starts
% Solution at Internal grid points at each time level
for L=2:LL
M1 = U(L+1,J+1);
M2 = U(L+1,J);
M3 = U(L,J+1);
M4 = U(L,J);
M5 = U(L-1,J+1);
M6 = U(L-1,J);
N1 = (1/(2*K))*(M5+M3-M6-M4);
N2 = (M5+M3+M6+M4)*(M5+M3+M6+M4-2)*(M5+M3+M6+M4-2*GAMMA);
N3 = (M5+M3++M6+M4);
N4 = (1/(2*SGM*H(L)))*(M5+M6-M3-M4);
N5 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M5+M6-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M1+M2));
N6 = (1/(2*K))*(M5+M3-M6-M4)+(ALPHA/8)*(M5+M6+M3+M4)*(M5+M6+M3+M4)+(BETA/64)*(M5+M6+M3+M4)*(M5+M6+M3+M4-4)*(M5+M6+M3+M4-4*GAMMA);
N7 = (1/(2*K))*(M1+M3-M2-M4);
N8 = (M1+M3+M2+M4)*(M1+M3+M2+M4-2)*(M1+M3+M2+M4-2*GAMMA);
N9 = (M1+M3++M2+M4);
N10 = (1/(2*SGM*H(L)))*(M1+M2-M3-M4);
N11 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M1+M2-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M5+M6));
N12 = (1/(2*K))*(M1+M3-M2-M4)+(ALPHA/8)*(M1+M2+M3+M4)*(M1+M2+M3+M4)+(BETA/64)*(M1+M2+M3+M4)*(M1+M2+M3+M4-4)*(M1+M2+M3+M4-4*GAMMA);
N13 = (1/K)*(M3-M4);
N14 = (1/K)*(M1-M2)-(1+SGM)*N13+(SGM/K)*(M5-M6);
N15= (M3+M4)/(2);
N16 = M1+M2+(1+SGM)*(M3+M4)+SGM*(M5+M6);
N17 = M1+M2-(1-(SGM^2))*(M3+M4)-(SGM)^2*(M5+M6);
N18 = (1/(2*K))*(M1+M3-M2-M4);
N19 =N9^2;
N21 = M5+M3-M6-M4;
N22 = N3^2;
O1 = N1+(BETA/16)*(N2)+(ALPHA/4)*(N3)*(N4+(H(L)/4)*(2*BB2*N5-CC*N6));
O2 = N7+(BETA/16)*(N8)+(ALPHA/4)*(N9)*(N10+(H(L)/4)*(2*BB1*N11-AA*N12));
O3 = N13+c*N14+ALPHA*(N15+(a/SGM*(1+SGM))*N16)*(1/2*H(L)*SGM*(1+SGM))*N17 + b*H(L)*[N18+(ALPHA/8)*N19 + (BETA/16)*N9*(N9-4)*(N9-4*GAMMA)-(N21+(ALPHA/8)*(N3)^2)+(BETA/16)*(N3)*(N3-4)*(N3-4*GAMMA)]+BETA*[(N15+(a/(SGM*(SGM+1)))*N16)*(N15+(a/(2*SGM*(SGM+1)))*N16-1)*(N15+(a/(2*SGM*(SGM+1)))*N16-GAMMA)];
NAA = (EPS/2)*(M1+M2-2*M3-2*M4+M5+M6) – ((H.^2)/3)* (O1+O2+O3); %———————SPLINE IN COMPRESSION————————————————
% Numerical Solution of Burger’s Huxley equation
%E*Uxx=Ut+ALPHA*UUx+BETA*(U^3+DELTA*U^2+GAMMA*U)
% , U(x,t)=GAMMA*[1+tanh(a1*(x-a2*t))]/2, t>=0
%————————————————————————–
clear all; % clear all variables in memory
LAM=1.6;
%LL=10;
%JJ=1000; % Solution at t=1
LL=8;
JJ=40;
H=1/LL;
K=LAM*H*H;
K=0.01;
%LLL=(LL/10)+9;
H= (2*pi)/100;
SGM=1.0;
EPS=1.0;
ALPHA=1.0;
BETA=0.0;
GAMMA=0.0;
DELTA=1.0;
a= (-1/4)*(1-SGM+(SGM)^2);
b= -SGM/(3*(1+SGM));
c= (-1/(2*SGM*(1+SGM)))*(1-SGM+(SGM)^2);
%a1=GAMMA*(-ALPHA+sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA*GAMMA/2)+((2-GAMMA)*(ALPHA+sqrt((ALPHA^2)+8*BETA))/4);
%a1=(-ALPHA-sqrt((ALPHA^2)+8*BETA))/8;
%a2=(ALPHA/2)-((1-2*GAMMA)*(ALPHA-sqrt((ALPHA^2)+8*BETA))/4);
% LLL=(0.5*LL)+1;
%tt=(8.986818916*pi)/180;
%tt=8.986818916;
% %Spline in Tension
% tt=0.001;
% AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
% BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
% BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
% CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
% %spline in compression
tt=(8.986818916*pi)/180;
AA=(SGM*((tt/sin(tt))-cos(tt)))/(2*tt^2);
BB1=(SGM*(-(tt*cos(tt)/sin(tt))+1))/(2*tt^2);
BB2=(-(tt*cos(tt)/sin(tt))+1)/(2*tt^2);
CC=((tt/sin(tt))-cos(tt))/(2*tt^2);
%Cubic Spline
%AA=SGM/3;
%BB1=SGM/6;
%BB2=1/6;
%CC=1/3;
disp(‘Numerical Solution of 1D Parabolic Equation’);
disp(‘ ‘);
fprintf(‘LL=%4.2f, K=%6.4f, LAM=%6.2f n’,LL,K,LAM);
disp(‘ ‘);
% Dimensions
X=zeros(1,LL+1);
T=zeros(1,JJ+1);
TT=zeros(1,JJ+1);
U=zeros(LL+1,JJ+1);
EU=zeros(LL+1,JJ+1);
OLDU=zeros(LL+1,JJ+1);
H=zeros(1,LL);
if SGM==1
S=1;
for i=1:LL-1
S=S+SGM^i;
end;
% H(1)=2/S;
H(1)=1/S;
else
% H(1)=2*((1-SGM)/(1-(SGM^LL)));
H(1)=((1-SGM)/(1-(SGM^LL)));
end
% Formation of Variable step lengths
for L=1:LL-1
H(L+1)=SGM*H(L);
end
% Formation of Nodal Points
% X(1)=-1.0;
X(1)=0.0;
for L=2:LL
for J=1:JJ+1
X(L)=X(L-1)+H(L-1);
T(J)=(J-1)*K;
end
end
X(LL+1)=1.0;
for L=1:LL+1
for J=1:JJ+1
% EU(L,J)=GAMMA*(1+tanh(a1*(X(L)-a2*T(J))))/2;
% EU(L,J)=(1+tanh(a1*(X(L)-a2*T(J))))/2;
EU(L,J)= exp(-T(J))*sin(X(L));
end
end
% Initial conditions
for L=1:LL+1
%U(L,1)=EU(L,1);
U(L,1)=cos(pi*X(L));
end
% Boundary conditions
for J=2:JJ+1
%U(0,J)==EU(0,J);
U(1,J)=exp(-EPS*(pi)^2*T(J));
U(2,J)=-exp(-EPS*(pi)^2*T(J));
%U(1,J)=EU(1,J)==-exp(-EPS*(pi)^2*t);;
U(LL+1,J)=EU(LL+1,J);
end
% Solution at advanced time level
tic % CPU time starts
for J=1:JJ
% Initial & First Approx
for L=2:LL
OLDU(L,J+1)=EU(L,J+1);
U(L,J+1)=OLDU(L,J+1);
end
for KK=1:1200 %Iteration starts
% Solution at Internal grid points at each time level
for L=2:LL
M1 = U(L+1,J+1);
M2 = U(L+1,J);
M3 = U(L,J+1);
M4 = U(L,J);
M5 = U(L-1,J+1);
M6 = U(L-1,J);
N1 = (1/(2*K))*(M5+M3-M6-M4);
N2 = (M5+M3+M6+M4)*(M5+M3+M6+M4-2)*(M5+M3+M6+M4-2*GAMMA);
N3 = (M5+M3++M6+M4);
N4 = (1/(2*SGM*H(L)))*(M5+M6-M3-M4);
N5 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M5+M6-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M1+M2));
N6 = (1/(2*K))*(M5+M3-M6-M4)+(ALPHA/8)*(M5+M6+M3+M4)*(M5+M6+M3+M4)+(BETA/64)*(M5+M6+M3+M4)*(M5+M6+M3+M4-4)*(M5+M6+M3+M4-4*GAMMA);
N7 = (1/(2*K))*(M1+M3-M2-M4);
N8 = (M1+M3+M2+M4)*(M1+M3+M2+M4-2)*(M1+M3+M2+M4-2*GAMMA);
N9 = (M1+M3++M2+M4);
N10 = (1/(2*SGM*H(L)))*(M1+M2-M3-M4);
N11 = (1/K)*(M3-M4)+(BETA/8)*(M3+M4)*(M3+M4-2)*(M3+M4-2*GAMMA)+(ALPHA/2)*(M3+M4)*(1/(2*SGM*H(L)*(SGM+1)))*(M1+M2-(1-(SGM)^2)*(M3+M4)-((SGM)^2)*(M5+M6));
N12 = (1/(2*K))*(M1+M3-M2-M4)+(ALPHA/8)*(M1+M2+M3+M4)*(M1+M2+M3+M4)+(BETA/64)*(M1+M2+M3+M4)*(M1+M2+M3+M4-4)*(M1+M2+M3+M4-4*GAMMA);
N13 = (1/K)*(M3-M4);
N14 = (1/K)*(M1-M2)-(1+SGM)*N13+(SGM/K)*(M5-M6);
N15= (M3+M4)/(2);
N16 = M1+M2+(1+SGM)*(M3+M4)+SGM*(M5+M6);
N17 = M1+M2-(1-(SGM^2))*(M3+M4)-(SGM)^2*(M5+M6);
N18 = (1/(2*K))*(M1+M3-M2-M4);
N19 =N9^2;
N21 = M5+M3-M6-M4;
N22 = N3^2;
O1 = N1+(BETA/16)*(N2)+(ALPHA/4)*(N3)*(N4+(H(L)/4)*(2*BB2*N5-CC*N6));
O2 = N7+(BETA/16)*(N8)+(ALPHA/4)*(N9)*(N10+(H(L)/4)*(2*BB1*N11-AA*N12));
O3 = N13+c*N14+ALPHA*(N15+(a/SGM*(1+SGM))*N16)*(1/2*H(L)*SGM*(1+SGM))*N17 + b*H(L)*[N18+(ALPHA/8)*N19 + (BETA/16)*N9*(N9-4)*(N9-4*GAMMA)-(N21+(ALPHA/8)*(N3)^2)+(BETA/16)*(N3)*(N3-4)*(N3-4*GAMMA)]+BETA*[(N15+(a/(SGM*(SGM+1)))*N16)*(N15+(a/(2*SGM*(SGM+1)))*N16-1)*(N15+(a/(2*SGM*(SGM+1)))*N16-GAMMA)];
NAA = (EPS/2)*(M1+M2-2*M3-2*M4+M5+M6) – ((H.^2)/3)* (O1+O2+O3); #differentiate, #code, #pde MATLAB Answers — New Questions
Is Sine Wave Function Block the best for Signal Creation?
Trying to simulate the tilting of a engine nacelle on a tilt-rotor aircraft and only know nacelle tilt velocity, 10 rad/s, and tilting range from 0 to 90 degrees. Position graph should be 12-15 secs but instead is 4 secs. Is this an acccurate way to simulate input signal or do I need to adjust input parameters of sine wave function block? Any tips/pointers would be greatly appreciated!Trying to simulate the tilting of a engine nacelle on a tilt-rotor aircraft and only know nacelle tilt velocity, 10 rad/s, and tilting range from 0 to 90 degrees. Position graph should be 12-15 secs but instead is 4 secs. Is this an acccurate way to simulate input signal or do I need to adjust input parameters of sine wave function block? Any tips/pointers would be greatly appreciated! Trying to simulate the tilting of a engine nacelle on a tilt-rotor aircraft and only know nacelle tilt velocity, 10 rad/s, and tilting range from 0 to 90 degrees. Position graph should be 12-15 secs but instead is 4 secs. Is this an acccurate way to simulate input signal or do I need to adjust input parameters of sine wave function block? Any tips/pointers would be greatly appreciated! sine wave function, saturation, integrator, derivative, tilt rotor nacelle angle MATLAB Answers — New Questions
如何通过给定的方程或不等式作出空间图形(或部分图形)
题目:绘制球体x^2+y^2+z^2<=16与圆柱面x^2+y^2=4x所截的空间立体图形。
我的代码是:
%绘制球面
phi=0:0.1:pi;
theta=-pi:0.1:pi;
[phi,theta]=meshgrid(phi,theta);
x1=4.*sin(phi).*cos(theta);
y1=4.*sin(phi).*sin(theta);
z1=4.*cos(phi);
surf(x1,y1,z1)
hold on
%绘制柱面
s=-5:0.1:5;
t=-pi:0.1:pi;
[s,t]=meshgrid(s,t);
x2=2+2*cos(t);
y2=2*sin(t);
z2=s;
surf(x2,y2,z2)
运行结果显示是两个空间曲面相交而成的图形。
我的问题:如何绘出在第一卦限部分的立体?
尝试:我通过更改参数的范围好像不能达到理想的图形。题目:绘制球体x^2+y^2+z^2<=16与圆柱面x^2+y^2=4x所截的空间立体图形。
我的代码是:
%绘制球面
phi=0:0.1:pi;
theta=-pi:0.1:pi;
[phi,theta]=meshgrid(phi,theta);
x1=4.*sin(phi).*cos(theta);
y1=4.*sin(phi).*sin(theta);
z1=4.*cos(phi);
surf(x1,y1,z1)
hold on
%绘制柱面
s=-5:0.1:5;
t=-pi:0.1:pi;
[s,t]=meshgrid(s,t);
x2=2+2*cos(t);
y2=2*sin(t);
z2=s;
surf(x2,y2,z2)
运行结果显示是两个空间曲面相交而成的图形。
我的问题:如何绘出在第一卦限部分的立体?
尝试:我通过更改参数的范围好像不能达到理想的图形。 题目:绘制球体x^2+y^2+z^2<=16与圆柱面x^2+y^2=4x所截的空间立体图形。
我的代码是:
%绘制球面
phi=0:0.1:pi;
theta=-pi:0.1:pi;
[phi,theta]=meshgrid(phi,theta);
x1=4.*sin(phi).*cos(theta);
y1=4.*sin(phi).*sin(theta);
z1=4.*cos(phi);
surf(x1,y1,z1)
hold on
%绘制柱面
s=-5:0.1:5;
t=-pi:0.1:pi;
[s,t]=meshgrid(s,t);
x2=2+2*cos(t);
y2=2*sin(t);
z2=s;
surf(x2,y2,z2)
运行结果显示是两个空间曲面相交而成的图形。
我的问题:如何绘出在第一卦限部分的立体?
尝试:我通过更改参数的范围好像不能达到理想的图形。 方程,不等式,图形 MATLAB Answers — New Questions
How to write the sum of several matrices in Matlab ?
We have the sequence of matrices
B(i,j,n)=2/N exp(-cn^2 ) sin(nx_i ) sin(n y_j )
where N and n are integers ,x_i and y_ji are real numbers in the
interval [0 ,1] and c is a real parameter strictly positive.
We pose
A(c)= ∑_B(n) for n=1,….,10
How to write in Matlab the sum A(c) ?We have the sequence of matrices
B(i,j,n)=2/N exp(-cn^2 ) sin(nx_i ) sin(n y_j )
where N and n are integers ,x_i and y_ji are real numbers in the
interval [0 ,1] and c is a real parameter strictly positive.
We pose
A(c)= ∑_B(n) for n=1,….,10
How to write in Matlab the sum A(c) ? We have the sequence of matrices
B(i,j,n)=2/N exp(-cn^2 ) sin(nx_i ) sin(n y_j )
where N and n are integers ,x_i and y_ji are real numbers in the
interval [0 ,1] and c is a real parameter strictly positive.
We pose
A(c)= ∑_B(n) for n=1,….,10
How to write in Matlab the sum A(c) ? sum, matrices MATLAB Answers — New Questions
Can I open scripts in the same window as the command window?
I have MATLAB R2015a and was wondering if there was a way to open the scripts and/or functions window within the main application without it opening a second window specifically for the script/function. I just want to reduce some of the clutter and simplify the work without going between pages.
Thank you.I have MATLAB R2015a and was wondering if there was a way to open the scripts and/or functions window within the main application without it opening a second window specifically for the script/function. I just want to reduce some of the clutter and simplify the work without going between pages.
Thank you. I have MATLAB R2015a and was wondering if there was a way to open the scripts and/or functions window within the main application without it opening a second window specifically for the script/function. I just want to reduce some of the clutter and simplify the work without going between pages.
Thank you. script, code editor, docking MATLAB Answers — New Questions
how to plot directly from value in app designer?
i am not very familiar with app designer. i want to make a calculator like above, while plotting graph from values from insulin concentration as y-axis and time as x-axis.do i need to tabulate the values then plot or i can straight away plot from the values?i am not very familiar with app designer. i want to make a calculator like above, while plotting graph from values from insulin concentration as y-axis and time as x-axis.do i need to tabulate the values then plot or i can straight away plot from the values? i am not very familiar with app designer. i want to make a calculator like above, while plotting graph from values from insulin concentration as y-axis and time as x-axis.do i need to tabulate the values then plot or i can straight away plot from the values? graph, app designer MATLAB Answers — New Questions
The training and validation accuracy stuck in the value of 74% in Resnet 50
I’m new to the world of Deep Learning and I’m attempting to classify sequences of proteins into two classes using scalogram images [class1=192, class2=171] I’ve implemented Transfer Learning with ResNet 50 as my model architecture.the accuracy in The training and validation stuck in 73-78 %.Anyone can explain to me what happen because I confused
The sample data : [class1]:
The sample data : [class2]:
as you see the pictures in both groups look very similar
The code:
[imdsTrain,imdsVal]= splitEachLabel(imds,0.7,"Randomized");
aug= imageDataAugmenter("RandYReflection",true,"RandXReflection",true)
augTrain = augmentedImageDatastore([224,224],imdsTrain,"DataAugmentation",aug);
augVal = augmentedImageDatastore([224,224],imdsVal);
options =trainingOptions("sgdm",…
"InitialLearnRate",3e-4,…
"MaxEpochs",100,…
"Plots","training-progress",…
"Shuffle","every-epoch",…
"ValidationData",augVal,…
"ValidationFrequency",1,…
"MiniBatchSize",128,…
"L2Regularization",1e-4)
net = resnet50;
lgraph = layerGraph(net);
fclayer = lgraph.Layers(end-2);
newFclayer = fullyConnectedLayer(2,"Name","NewFc",’BiasL2Factor’,10,"WeightL2Factor",10);
lgraph = replaceLayer(lgraph,fclayer.Name,newFclayer);
classlayer = lgraph.Layers(end);
newClassLayer = classificationLayer("Name","newClassLayer");
lgraph= replaceLayer(lgraph,classlayer.Name,newClassLayer);
net = trainNetwork(augTrain,lgraph,options);
The Training process:I’m new to the world of Deep Learning and I’m attempting to classify sequences of proteins into two classes using scalogram images [class1=192, class2=171] I’ve implemented Transfer Learning with ResNet 50 as my model architecture.the accuracy in The training and validation stuck in 73-78 %.Anyone can explain to me what happen because I confused
The sample data : [class1]:
The sample data : [class2]:
as you see the pictures in both groups look very similar
The code:
[imdsTrain,imdsVal]= splitEachLabel(imds,0.7,"Randomized");
aug= imageDataAugmenter("RandYReflection",true,"RandXReflection",true)
augTrain = augmentedImageDatastore([224,224],imdsTrain,"DataAugmentation",aug);
augVal = augmentedImageDatastore([224,224],imdsVal);
options =trainingOptions("sgdm",…
"InitialLearnRate",3e-4,…
"MaxEpochs",100,…
"Plots","training-progress",…
"Shuffle","every-epoch",…
"ValidationData",augVal,…
"ValidationFrequency",1,…
"MiniBatchSize",128,…
"L2Regularization",1e-4)
net = resnet50;
lgraph = layerGraph(net);
fclayer = lgraph.Layers(end-2);
newFclayer = fullyConnectedLayer(2,"Name","NewFc",’BiasL2Factor’,10,"WeightL2Factor",10);
lgraph = replaceLayer(lgraph,fclayer.Name,newFclayer);
classlayer = lgraph.Layers(end);
newClassLayer = classificationLayer("Name","newClassLayer");
lgraph= replaceLayer(lgraph,classlayer.Name,newClassLayer);
net = trainNetwork(augTrain,lgraph,options);
The Training process: I’m new to the world of Deep Learning and I’m attempting to classify sequences of proteins into two classes using scalogram images [class1=192, class2=171] I’ve implemented Transfer Learning with ResNet 50 as my model architecture.the accuracy in The training and validation stuck in 73-78 %.Anyone can explain to me what happen because I confused
The sample data : [class1]:
The sample data : [class2]:
as you see the pictures in both groups look very similar
The code:
[imdsTrain,imdsVal]= splitEachLabel(imds,0.7,"Randomized");
aug= imageDataAugmenter("RandYReflection",true,"RandXReflection",true)
augTrain = augmentedImageDatastore([224,224],imdsTrain,"DataAugmentation",aug);
augVal = augmentedImageDatastore([224,224],imdsVal);
options =trainingOptions("sgdm",…
"InitialLearnRate",3e-4,…
"MaxEpochs",100,…
"Plots","training-progress",…
"Shuffle","every-epoch",…
"ValidationData",augVal,…
"ValidationFrequency",1,…
"MiniBatchSize",128,…
"L2Regularization",1e-4)
net = resnet50;
lgraph = layerGraph(net);
fclayer = lgraph.Layers(end-2);
newFclayer = fullyConnectedLayer(2,"Name","NewFc",’BiasL2Factor’,10,"WeightL2Factor",10);
lgraph = replaceLayer(lgraph,fclayer.Name,newFclayer);
classlayer = lgraph.Layers(end);
newClassLayer = classificationLayer("Name","newClassLayer");
lgraph= replaceLayer(lgraph,classlayer.Name,newClassLayer);
net = trainNetwork(augTrain,lgraph,options);
The Training process: cnn, deep learning, computer vision MATLAB Answers — New Questions
Need help to run the Matlab code
Hello,
I am new to Matlab and I need to run the github repository code (https://github.com/singhdeepak-15/IMAGE_SEGMENT_ABC). But I am getting a lot of errors may be I am not running it correctly. Moreover, the output image is also not being displayed.
Can anyone help me in this regard?
Thank youHello,
I am new to Matlab and I need to run the github repository code (https://github.com/singhdeepak-15/IMAGE_SEGMENT_ABC). But I am getting a lot of errors may be I am not running it correctly. Moreover, the output image is also not being displayed.
Can anyone help me in this regard?
Thank you Hello,
I am new to Matlab and I need to run the github repository code (https://github.com/singhdeepak-15/IMAGE_SEGMENT_ABC). But I am getting a lot of errors may be I am not running it correctly. Moreover, the output image is also not being displayed.
Can anyone help me in this regard?
Thank you help, matlab code, image segmentation MATLAB Answers — New Questions
Dear friends, pls how can I call up the weights and bias of a trained model and write the mathematical expression or equation for it.
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 23-Jan-2023 17:53:08
%
% This script assumes these variables are defined:
%
% Input – input data.
% Target – target data.
x = Input;
t = Target;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% ‘trainlm’ is usually fastest.
% ‘trainbr’ takes longer but may be better for challenging problems.
% ‘trainscg’ uses less memory. Suitable in low memory situations.
trainFcn = ‘trainbr’; % Bayesian Regularization backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {‘removeconstantrows’,’mapminmax’};
net.output.processFcns = {‘removeconstantrows’,’mapminmax’};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivision
net.divideFcn = ‘dividerand’; % Divide data randomly
net.divideMode = ‘sample’; % Divide up every sample
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = ‘mse’; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {‘plotperform’,’plottrainstate’,’ploterrhist’, …
‘plotregression’, ‘plotfit’};
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
% Deployment
% Change the (false) values to (true) to enable the following code blocks.
% See the help for each generation function for more information.
if (false)
% Generate MATLAB function for neural network for application
% deployment in MATLAB scripts or with MATLAB Compiler and Builder
% tools, or simply to examine the calculations your trained neural
% network performs.
genFunction(net,’myNeuralNetworkFunction’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a matrix-only MATLAB function for neural network code
% generation with MATLAB Coder tools.
genFunction(net,’myNeuralNetworkFunction’,’MatrixOnly’,’yes’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a Simulink diagram for simulation or deployment with.
% Simulink Coder tools.
gensim(net);
end
=====================================================================
I have attached the save model, where output (Ra = Y) and inputs X(vc, ap, and f). I want to express the model equation for Ra interms of vc, ap, and f (x1, x2, and x3).% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 23-Jan-2023 17:53:08
%
% This script assumes these variables are defined:
%
% Input – input data.
% Target – target data.
x = Input;
t = Target;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% ‘trainlm’ is usually fastest.
% ‘trainbr’ takes longer but may be better for challenging problems.
% ‘trainscg’ uses less memory. Suitable in low memory situations.
trainFcn = ‘trainbr’; % Bayesian Regularization backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {‘removeconstantrows’,’mapminmax’};
net.output.processFcns = {‘removeconstantrows’,’mapminmax’};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivision
net.divideFcn = ‘dividerand’; % Divide data randomly
net.divideMode = ‘sample’; % Divide up every sample
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = ‘mse’; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {‘plotperform’,’plottrainstate’,’ploterrhist’, …
‘plotregression’, ‘plotfit’};
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
% Deployment
% Change the (false) values to (true) to enable the following code blocks.
% See the help for each generation function for more information.
if (false)
% Generate MATLAB function for neural network for application
% deployment in MATLAB scripts or with MATLAB Compiler and Builder
% tools, or simply to examine the calculations your trained neural
% network performs.
genFunction(net,’myNeuralNetworkFunction’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a matrix-only MATLAB function for neural network code
% generation with MATLAB Coder tools.
genFunction(net,’myNeuralNetworkFunction’,’MatrixOnly’,’yes’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a Simulink diagram for simulation or deployment with.
% Simulink Coder tools.
gensim(net);
end
=====================================================================
I have attached the save model, where output (Ra = Y) and inputs X(vc, ap, and f). I want to express the model equation for Ra interms of vc, ap, and f (x1, x2, and x3). % Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 23-Jan-2023 17:53:08
%
% This script assumes these variables are defined:
%
% Input – input data.
% Target – target data.
x = Input;
t = Target;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% ‘trainlm’ is usually fastest.
% ‘trainbr’ takes longer but may be better for challenging problems.
% ‘trainscg’ uses less memory. Suitable in low memory situations.
trainFcn = ‘trainbr’; % Bayesian Regularization backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {‘removeconstantrows’,’mapminmax’};
net.output.processFcns = {‘removeconstantrows’,’mapminmax’};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivision
net.divideFcn = ‘dividerand’; % Divide data randomly
net.divideMode = ‘sample’; % Divide up every sample
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = ‘mse’; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {‘plotperform’,’plottrainstate’,’ploterrhist’, …
‘plotregression’, ‘plotfit’};
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
% Deployment
% Change the (false) values to (true) to enable the following code blocks.
% See the help for each generation function for more information.
if (false)
% Generate MATLAB function for neural network for application
% deployment in MATLAB scripts or with MATLAB Compiler and Builder
% tools, or simply to examine the calculations your trained neural
% network performs.
genFunction(net,’myNeuralNetworkFunction’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a matrix-only MATLAB function for neural network code
% generation with MATLAB Coder tools.
genFunction(net,’myNeuralNetworkFunction’,’MatrixOnly’,’yes’);
y = myNeuralNetworkFunction(x);
end
if (false)
% Generate a Simulink diagram for simulation or deployment with.
% Simulink Coder tools.
gensim(net);
end
=====================================================================
I have attached the save model, where output (Ra = Y) and inputs X(vc, ap, and f). I want to express the model equation for Ra interms of vc, ap, and f (x1, x2, and x3). bias, weights, model formulation MATLAB Answers — New Questions