# How to modify this script

1 ビュー (過去 30 日間)
FG 2020 年 9 月 8 日

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
.
.
.
-----------------------------------------------------------------------------------
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);
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 件のコメント

FG 2020 年 9 月 9 日
Any help ?
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
FG 2020 年 9 月 9 日
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..

サインインしてコメントする。

### 採用された回答

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'

#### 1 件のコメント

FG 2020 年 9 月 9 日
Thank you.. I understand what you mean and you got it done ! Problem solved, thanx again..

サインインしてコメントする。

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by