How to modify this script
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2020-9-9
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
采纳的回答
Walter Roberson
2020-9-9
编辑:Walter Roberson
2020-9-9
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'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!