How to modify this script

1 visualización (últimos 30 días)
FG
FG el 8 de Sept. de 2020
Editada: Walter Roberson el 9 de Sept. de 2020
I have an M file as shown in the figure. What I want to do is; Instead of naming the cases like: 1111, 1112,1113...3452, 3453, 3454 I want to name them according to the states they are in like:
Case 1111 should be; Power Factor=0.95, PL=14500, FG=500, Angle=0, Nt=1
Case 1112 should be; Power Factor=0.95, PL=14500, FG=500, Angle=0, Nt=2
.
.
.
Would be pleased if you could help me about it.. Thnx
-----------------------------------------------------------------------------------
Q=[atan(18.19) atan(25.84) atan(31.78)];
P=[14500 10000 5000 500];
Ang=[0 10 20 30 40];
NT=[1 2 5 10];
for m=1:length(Q)
QM=Q(m)
for i=1:length(P)
PL=P(i);QL=QM*PL;FG=15000-P(i);
for k=1:length(Ang)
Ang_A=Ang(k);
Ang_B=Ang(k);
Ang_C=Ang(k);
for l=1:length(NT)
Nt=NT(l);
sim('islanding_UW_New_Loads_Fasilali_oran_SonTHD_Deneme')
t=harm_ratio.time;
HV3=harm_ratio.signals(1).values;
HV5=harm_ratio.signals(2).values;
HV7=harm_ratio.signals(3).values;
thd=THD.signals(1).values;
c=sprintf('Case%d%d%d%d',[m,i,k,l])
save(c)
end
end
end
end
  3 comentarios
Walter Roberson
Walter Roberson el 9 de Sept. de 2020
Which variable corresponds to Power factor? I do not seem to find any 0.95 or anything reasonably close in your computations.
PL appears to be variable PL
FG apppears to be variable FG
Angle is ambiguous as to whether it is ANG_A, ANG_B, or ANG_C. All three are set to the same value in the code, so it is not obvious why you have three separate variables, and the differences between them might be important later, perhaps.
Nt appears to be variable Nt
FG
FG el 9 de Sept. de 2020
Q=[atan(18.19) atan(25.84) atan(31.78)] is for Power Factor and cause system is three phase, Angles are Ang_C, Ang_B and Ang_C.. I just want to name the cases according to these criteria istead of 1111, 1112 etc..

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Sept. de 2020
Editada: Walter Roberson el 9 de Sept. de 2020
c = sprintf('Power Factor=%.2f, PL=%g, FG=%g, Angle=%g, Nt=%g.mat', QM, PL, FG, Ang_A, Nt);
It is not clear that having a 54 character filename is desireable ?
Your Q values are 1.51587634897992 1.53211593878758 1.53934037485646 which do not look anything like 0.95 to me.
I used %.2f in the format, which will round to 2 decimal places. For your Q values that will be 1.52 1.53 and 1.54 . It looks to me as if you might be advised to use at least one more decimal place.
Note: Unless you used formats with particular width and leading 0 filling, like %05.2f then your files will not sort in numeric order. For example, 'Power Factor=10.7' sorts before 'Power Factor=2.9'
  1 comentario
FG
FG el 9 de Sept. de 2020
Thank you.. I understand what you mean and you got it done ! Problem solved, thanx again..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by