how to use external function in app designer?

i have created a matlab fuction which will print multiple output how to use it in app designer.i called that fuction but i got an error that multiple outputs to print.what to do now?

Respuestas (1)

Cris LaPierre
Cris LaPierre el 22 de Jun. de 2022

0 votos

9 comentarios

GOURANG UPADHYAY
GOURANG UPADHYAY el 22 de Jun. de 2022
Editada: GOURANG UPADHYAY el 22 de Jun. de 2022
this will not work for me.i have already seen it.
function faultfrequency(N1,Ra)
T1=31;T2=106;T3=56;T4=108;%Number of teeth on each gear
N2=T1*N1/T2;N3=N2*T3/T4;%RPM calculation
%%Bearing Fault Frequency calculation
%1.Spherical Roller Bearing SKF 22316 B1
%D1 Shoulder/recess diameter of outer ring
%d2 Shoulder diameter of inner ring
%BD Rolling Element dia
%Pd Pitch dia
%Nd NUmber of Rolling Elemrnt
D1=143;d2=98.3;ca=12.95;Nb=15;Pd=(D1+d2)/2;Bd=12.15*2;N=N1;
BPFO1=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));%Ball Pass Frequency Outer
BPFI1=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));%Ball Pass Frequency Inner
BSF1=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);%Ball Spin Frequency
FTF1=(N/120)*(1-((Bd/Pd)*cosd(ca)));%Fundamental Train Frequency
%Cylindrical Roller Bearing SKF NJ 2212 ECJ B2
F=72;Bd=14;ca=0;Nb=16;D=F+(2*Bd);Pd=(D+F)/2;N=N1;
BPFO2=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI2=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF2=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF2=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Spherical Roller Bearing SKF 22316 E B3
D1=143;d2=98.3;ca=12.95;Nb=15;Pd=(D1+d2)/2;Bd=12.15*2;N=N2;
BPFO3=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI3=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF3=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF3=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Cylindrical Roller Bearing SKF NJ 2310 ECP B4
F=65;Bd=16;ca=0;Nb=23;D=F+(2*Bd);Pd=(D+F)/2;N=N2;
BPFO4=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI4=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF4=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF4=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Cylindrical Roller Bearing SKF NJ 218 ECP B5
F=107;Bd=19;ca=0;Nb=17;D=F+(2*Bd);Pd=(F+D)/2;N=N3;
BPFO5=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI5=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF5=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF5=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Spherical Roller Thrust Bearing SKF 29436E B6
Bd=16.61;ca=44.01;Nb=15;Pd=171.5;N=N3;
BPFO6=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI6=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF6=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF6=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Cylindrical Roller Bearing SKF NJ 217 ECP
F=100.5;Bd=18;ca=0;Nb=17;D=F+(2*Bd);Pd=(D+F)/2;N=N3;
BPFO7=(N*Nb/120)*(1-((Bd/Pd)*cosd(ca)));
BPFI7=(N*Nb/120)*(1+((Bd/Pd)*cosd(ca)));
BSF7=(Pd*N/(Bd*60))*(1-((Bd/Pd)*cosd(ca))^2);
FTF7=(N/120)*(1-((Bd/Pd)*cosd(ca)));
%Harmonics
ff=zeros(28,5);
no=[1,5,9,13,17,21,25];
for i=no
for j=1:5
switch i
case 1
ff(i,j)=BPFO1*j;
ff(i+1,j)=BPFI1*j;
ff(i+2,j)=BSF1*j;
ff(i+3,j)=FTF1*j;
case 5
ff(i,j)=BPFO2*j;
ff(i+1,j)=BPFI2*j;
ff(i+2,j)=BSF2*j;
ff(i+3,j)=FTF2*j;
case 9
ff(i,j)=BPFO3*j;
ff(i+1,j)=BPFI3*j;
ff(i+2,j)=BSF3*j;
ff(i+3,j)=FTF3*j;
case 13
ff(i,j)=BPFO4*j;
ff(i+1,j)=BPFI4*j;
ff(i+2,j)=BSF4*j;
ff(i+3,j)=FTF4*j;
case 17
ff(i,j)=BPFO5*j;
ff(i+1,j)=BPFI5*j;
ff(i+2,j)=BSF5*j;
ff(i+3,j)=FTF5*j;
case 21
ff(i,j)=BPFO6*j;
ff(i+1,j)=BPFI6*j;
ff(i+2,j)=BSF6*j;
ff(i+3,j)=FTF6*j;
case 25
ff(i,j)=BPFO7*j;
ff(i+1,j)=BPFI7*j;
ff(i+2,j)=BSF7*j;
ff(i+3,j)=FTF7*j;
end
end
end
for a=1:28
for b=1:5
ul=ff(a,b)*2^(1/6);
ll=ff(a,b)*2^(-1/6);
if a<=4
x=1;
elseif a>4 && a<=8
x=2;
elseif a>8 && a<=12
x=3;
elseif a>12 && a<=16
x=4;
elseif a>16 && a<=20
x=5;
elseif a>20 && a<=24
x=6;
elseif a>24 && a<=28
x=7;
end
b1=1:4:28;
b2=2:4:28;
b3=3:4:28;
b4=4:4:28;
if ll<=Ra && ul>=Ra
if ismember(a,b1)==1
fprintf("defect is in outer race of bearing %d and corresponding harmonics is %d and value is %d:\n ",x,b,ff(a,b))
elseif ismember(a,b2)==1
fprintf("defect is in outer race of bearing %d and corresponding harmonics is %d and value is %d:\n ",x,b,ff(a,b))
elseif ismember(a,b3)==1
fprintf("defect is in outer race of bearing %d and corresponding harmonics is %d and value is %d:\n ",x,b,ff(a,b))
elseif ismember(a,b4)==1
fprintf("defect is in outer race of bearing %d and corresponding harmonics is %d and value is %d:\n ",x,b,ff(a,b))
else
fprintf("No bearing defect:\n")
end
end
end
end
%% Gear fault frequencies
%input satge
GMF1=T1*N1/60;%Gear Meash Frequency
NA1=gcd(T1,T2);%Number of Assembly Phases
HTF1=(GMF1*NA1)/(T1*T2);%Hunting Tooth Frequency
APF1=GMF1/NA1;%Assembly Phase Frequency
%input satge
GMF2=T3*N2/60;%Gear Meash Frequency
NA2=gcd(T3,T4);%Number of Assembly Phases
HTF2=(GMF2*NA2)/(T3*T4);%Hunting Tooth Frequency
APF2=GMF2/NA2;%Assembly Phase Frequency
fg=zeros(6,5);
nog=[1 4];
for i=nog
for j=1:5
if i==1
fg(i,j)=GMF1*j;
fg(i+1,j)=HTF1*j;
fg(i+2,j)=APF1*j;
elseif i==4
fg(i,j)=GMF2*j;
fg(i+1,j)=HTF2*j;
fg(i+2,j)=APF2*j;
end
end
end
for a=1:6
for b=1:5
ul=fg(a,b)*2^(1/6);
ll=fg(a,b)*2^(-1/6);
if a<=3
x=1;
elseif a>3 && a<=6
x=2;
end
b1=1:3:4;
b2=2:3:6;
b3=3:3:6;
if ll<=Ra && ul>=Ra
if ismember(a,b1)==1
fprintf("defect is in stage %d (check wear and lubrication)and corresponding harmonics of GMF is %d and corresponding frequency is %d\n ",x,b,fg(a,b))
elseif ismember(a,b2)==1
fprintf("defect is in stage %d and corresponding harmonics of HTF is %d and corresponding frequency is %d\n ",x,b,fg(a,b))
elseif ismember(a,b3)==1
fprintf("defect is in stage %d and corresponding harmonics of APF is %d and corresponding frequency is %d\n ",x,b,fg(a,b))
end
end
end
end
This is my function .please help
Cris LaPierre
Cris LaPierre el 22 de Jun. de 2022
Share your app, too. You can attach it using the paperclip icon.
ok
but how can i print all of these outputs in app
Cris LaPierre
Cris LaPierre el 22 de Jun. de 2022
I wouldn't use fprintf. Based on the little I know, I would use a text edit field (see all options here) and set the edit field value equal to the statement you are creating using fprintf.
please suggest how should i convert my function in to app i am stucked un to it .i am new to app designer and not able to understand it at all.
please reply
Cris LaPierre
Cris LaPierre el 22 de Jun. de 2022
Apologies. It was the middle of the night so I was sleeping. It is unclear to me what you are struggling to do now. Perhaps this Answer of custom functions will help:
Other suggestion include going through the app designer tutorial, and finding an example app to learn from.

Iniciar sesión para comentar.

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 22 de Jun. de 2022

Comentada:

el 22 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by